Posts Tagged ‘WordPress’
In previous posts, we have gone through some WordPress customization that involve code addition in
functions.php. These additions enhance the functionality of our theme.
Take our WordPress Login Page tutorial for example, we are able to redirect users from the default WordPress login page,
wp-login.php, to our new customized login page, and also redirect them to another page upon logout.
However, after a while, the list of codes that we’ve added in the
functions.php could pile up and get very messy. If you are experiencing this problem, we’ve got some tips here to help you tackle this.
Recommended Reading: Beginner’s Guide To WordPress Plugin Development
Creating Multiple Files
The first thing we can do to manage our codes is by separating a set of codes into different files. Say, we have a couple of new functions that alter the Login Page. We could store these codes in a new file rather than putting it in the
Create a new file,
custom-login.php (as an example), and put all the codes in it. Then, in function.php, refer to this file with
require_once, like so.
require_once get_template_directory() . '/inc/custom-login.php';
And that’s it. Note that this method requires you to be careful when separating the codes, otherwise you could break the site. You should also be very clear in naming the files, so that people who work on your theme – particularly, if you are working in a team – can quickly figure out the relationship between each file.
However, if you are not that familiar with PHP or are afraid of ruining the site when altering the files, try the next tip instead.
Code Snippet Plugin
Code Snippets is a plugin created by Shea Bunge. It provides a native WordPress GUI to add your code snippets, and run them on your site. In other words, instead of adding the code in
functions.php, you can do it through the WordPress back-end administration.
Once it is installed and activated, you will find a new side-menu below the Plugins.
You can create a new code snippet, just as you would create a new post and page.
Click on the Activate button to use the code in your site. So with this, we not only store the codes but can activate them to function within the site.
You can also hit the Export button to download the code in a PHP file.
One of the advantages of using Code Snippets is that instead of having to input all the codes in the
functions.php of the theme once again, the functionality of the codes will still be able to run, even if we have changed the theme.
Alright, those are the two tips that we’ve got. It is now up to you to decide on which one best fits your requirements. We hope you find these tips useful. If you know of any other methods, let us know in the comments.
As the current most-used CMS, WordPress has numerous plugins that enhances its capabilities. To name a few, there is a very popular plugin called WooCommerce that turns WordPress into a full-fledged e-commerce platform, and bbPress that allows one to run a forum on the site.
Apart from the plugins for general users, WordPress has quite a number that are aimed at developers too. If you are a developer looking to develop either a plugin or theme for WordPress, we have put together some essential and handy plugins that will help make the job much easier.
Recommended Reading: 50 Essential WordPress Plugins You Should Know
1. Debug Bar
Debug Bar adds a new menu called Debug at the admin bar. Click on the menu, and it will neatly display information like cache, total queries, total queried time, and memory usage that will be very useful in the debugging process. In addition, you may also see some PHP Warnings and Notices that occur when you enable
Some functions in WordPress have been deprecated, meaning they are no longer recommended for usage. Log Deprecated Notices is a plugin that will list all these functions as they are found in the plugin or theme and even show us alternatives.
Monster Widget is designed for WordPress theme developers. It contains all the 13 WordPress Core widgets – such as Text Widget, Category Widget, and Tag Cloud – in a single widget. It’s convenient, saves a lot of time and ensures that they are presented nicely in the theme.
If you often set a new size of image thumbnails, whether in your theme or plugin, you may find Regenerate Thumbnails useful. It allows you to regenerate all the thumbnail images in the library in the new size you want, with a single click. The process, however, may take a while depending on the amount of images – especially when you run it in a live site.
5. RTL Tester
Since there are many WordPress users out there who read and write from right-to-left (RTL), you might need to test your theme or plugin in RTL mode as well. Install RTL Tester, and a new button is added to the admin bar that enables you to switch between the right and left text direction.
This plugin adds a new column at the right side of the WordPress table that displays entry IDs. This way you can easily grab the ID for each entry including Posts, Pages, Categories, Media, Links, and Tags.
7. Theme Check
Theme Check is a must-install plugin for every WordPress theme developer. It measures the WordPress theme against the current WordPress coding standards and best practices. It also checks for required elements that need to be present in the theme such as the theme screenshot, licenses, and author information.
With User Switching, you can switch between registered users without having to repeatedly enter usernames and passwords. Once activated, you will see a new menu called Switch off in the admin bar, as you can see from the following screenshot. If you need a plugin that creates a new role with a set of new capabilities, this plugin will certainly come in handy.
This plugin allows you to reset WordPress to its initial state. It will remove the previous contents, additions, and customizations from the database. However, it does not remove the files that have been uploaded previously.
10. Beta Tester
Beta Tester lets you update to WordPress Beta, Release Candidate (RC), or Nightly version easily, which is useful to test the compatibility of your theme or plugin with the upcoming version.
11. Query Monitor
Query Monitor adds a new toolbar at the WordPress admin bar and shows query data along with a bunch of other features that have not yet been seen in other debugging plugins, and would be very helpful in the process. These include showing HTTP Requests, Transients, Redirects, Ajax Call, Hooks, and PHP Errors.
This plugin provides references for developing WordPress Admin UI. It includes references for jQuery UI Components, Forms, Helper Classes, and Dashicons, which is the new icon set used in MP6.
OpenShift is a platform-as-a-service from the open source leader, Redhat. It works on the open source OpenShift code running on RHEL systems. OpenShift can be used to host and run a variety of software, and it supports various open source technologies and databases. It has built-in support for several programming languages.
Do you want a free self-hosted WordPress blog? We’re going to demonstrate how to install and run an instance of WordPress blogging software on the OpenShift platform in just an hour.
Recommended Reading: How To Host Your Personal Website On Google’s Servers For Free
Good question! OpenShift is just a PAAS like many others, then what’s the fun in hosting your WordPress blog on RedHat’s platform? On top of easy code maintenance using Git, and support for PHP and MySQL, OpenShift comes with a free plan of 3 small gears.
What are gears? Gears are virtual containers with a set of resources that allows users to run their applications. An application can utilize many gears, and that’s what is known as scalability. Small gears provide 512MB RAM and 1GB disk quota under the free plan.
Set Up Your Self-Hosted WordPress Blog
It’s a simple three-step process:
- Create an OpenShift account
- Create an application using WordPress source code
- Configure WordPress’ required settings.
1. Create An OpenShift account
Sign up for OpenShift if you don’t already own an account. An OpenShift account is required to boot your application framework, submit your app’s code (using Git) and launch your WordPress application.
2. Create An Application
An application is simply a software running on the OpenShift platform. Unlike an application on your Android or Windows device, an application on OpenShift doesn’t demand all of the system’s resources, it only accesses the resources available to it in scale of gears. OpenShift also allows automatic scaling of gears for your application.
Follow the given steps to create an application:
1. Log in to the online console of OpenShift.
2. Choose Applications from the top menu.
3. Click on ‘Add Application…’ button.
4. Choose a type of application: Scroll below and select WordPress 3.x given under the "Instant App" section.
5. Configure the application: Enter your application name, which will be used to create your application’s public URL, and then click on ‘Create Application’ button.
6. Click on ‘No, continue’. You’ll be shown the details of your newly created application. Please make note of database credentials for your application as you may need it in the future.
Well done! You’ve created your WordPress application on the OpenShift platform.
3. Configure WordPress
You’ve started a WordPress application on OpenShift using the WordPress’ Git provided by the OpenShift team, but it’s still not completely configured. It’s just a software hosted on the servers and not a running blog yet. We need to configure the necessary options. Here are the steps:
1. Choose Applications from the top menu.
2. Choose your newly created app from the list.
3. Click on your app’s public URL given at the top. An example of such public URL is blog-aksinghnet.rhcloud.com.
4. Your newly created app gets opened in the browser. WordPress asks for the basics but require information to finalize the installation..
5. Fill them in like below:
- Site Title: Enter the title of your website. For example, Hongkiat.com, AKSingh.net, etc.
- Username: Enter a good username that’s not easy to guess. For example, ash34in85, hk493online58, etc.
- Password: Enter a secure password twice.
- Your E-mail: Enter your email.
- Privacy: Leave it checked.
6. Click on the ‘Install WordPress’ button. WordPress should greet you with success!
7. Finally, your blog is ready. Click on the ‘Log In’ button, provide your user credentials and you’ll get signed in to your own self-hosted WordPress. It’s exciting, isn’t it?
Congratulations for successfully setting up your free WordPress blog. A blog created using OpenShift is no different from any other self-hosted WordPress instance. The major difference is that this one is free and you need not go for a hosting plan to host your own WordPress. What are you waiting for? Log in to your WordPress and get creative!
You might also be interested in:
- How To Make Your Own Proxy Using Google App Engine
- Installing Google Custom Search Engine (CSE) On WordPress Site
- Beginner’s Guide To WordPress Multisite With MAMP
- ServerPress – Quick And Easy Way To Install WordPress Locally
Liveblogging is a popular way to cover an event in real-time – it is similar to a Twitter feed, only it happens on your own site. If you like to follow major key events like the Apple WWDC, you may find some tech blogs and news sites liveblogging to cover the event in real-time.
Some of the advantages of using liveblog is that the journalists can publish updates easily, while the readers can get the updates quickly. In addition, Liveblogging also allows for multiple writers, or journalists to contribute at the same time. If you want to also cover events on your site using Liveblog, we will show you how in this post.
Recommended Reading: Complete Guide To Live Blogging
The Liveblog Plugin
In WordPress, you can enable liveblog with the Liveblog plugin from Automattic – the guys behind WordPress. This plugin was exclusively released for WordPress VIP: it is a premium service in WordPress.com. Now, you can install and use it on your self-hosted sites.
Once activated, you can create a new post, and enable liveblog for it, like so.
Publish and view the post, and you will find a posting tool where you can publish updates right from the front-end of the post. We can also preview the post before publishing it.
To post an image, you can drag-and-drop the image from your folder onto the input field. It will automatically upload the image and put the image URL within the posting tool.
You can also embed a tweet or a Youtube video by simply putting in the link, like so.
If you want to make the post bold, italic, or add a link, you can wrap it in HTML Markup.
When the event ends, you can click the Archive button to put the Liveblog in Archive. This way the readers will still be able to read the contents, even after the posting tool has been disabled.
That’s it. You can give this plugin a try if you want to try liveblogging on your site. I hope you find this tip useful.
WordPress post and page editor is equipped with a WYSIWIG editor. We can write and format post as easy as we do it in a word processor application, such as Microsoft Word and Pages. But, WordPress also allows us to write and publish post through email.
There are some occasions where sending post by email can be very handful, e.g. when you accept contribution from others, but you do not want to give out an account for them. So, rather than diving through a bunch of email inboxes, this method allows you to find the post immediately in the WordPress back-end administration.
So, let’s see how it is done.
Recommended Reading: Enabling Infinite Scroll For WordPress Theme
Posting by email in a self-hosted WordPress site is achievable using Jetpack. Ensure that you have installed it, and that the feature is activated, as follows.
Then, go to Profile > Your Profile page, and enable Post by Email. This action will generate a unique email address where you will send the post. Any users with the “Publish Post” privilege, such as Author and Editor, may be required to create their own unique email address as well.
Please be aware that anyone with the email address can publish post to your blog, so you ought to keep this email address a secret.
Alright, we are done with the requirement setup. And, now, let’s head over to our Email app.
Sending out post through email
Write the post content as you would write an email. You can write it in plain text or rich text format, and specify the title of the post in the email Subject. Send it to the unique email address that has been generated above.
Login to WordPress back-end, and you should find that the post has been published. Note that users with Contributors status won’t be able to publish posts immediately; the post that they send will be pending review.
Furthermore, we can use shortcodes for configuring the post, such as whether the post is “published” or it is a “draft”; specifying the post categories and tags; and naming the post URL slug. The following is a list of shortcodes that you might need to include:
- [title Your post title] – you can also set the post title in this way.
- [slug some-url-name] – name the post slug URL.
- [category x,y,z] – specify the post categories. If the categories specified are not present, WordPress will create them for you.
- [tags x,y,z] – specify the post tags.
- [excerpt]some excerpt[/excerpt] – wrap the post excerpt.
- [delay +1 hour] – delay the post publishing time. It will automatically put the post in schedule.
- [comments on | off] – allows or disallows the post comments.
- [status publish | pending | draft | private] – set the post publishing status.
- [password secret-password] – set password for the post.
- [more] – split the post, display only the first part of the post.
- [nextpage] – split the post into pages.
For more shortcodes, check out this post.
There is no restriction on where to put the shortcodes. Here is an example.
Please note that this Post by Mail feature comes with limitations. At the time of the writing, assigning featured image thumbnail and send post to Custom Post Type is not possible.
In addition, I had some trouble when trying to insert images into the post through email attachment. The image is not uploaded and the src URL within the image is filled with random strings and numbers. To solve this, we can use an alternative: by uploading the image separately with the following format address media+[uniqename]@post.wordpress.com.
But if you ask me, Post by Mail is still very handful in certain situations.