Add a WordPress Admin User to the Database via PHP

As a developer, you will occasionally need to create a new administrative user in the database to gain access to the site. Typically, this is necessary when you are provided with an export of a WordPress database, but you aren’t provided with the login credentials for the admin user. Sure, you can gain access via…… Read More

Loading IE Conditional Stylesheets in WordPress

Most web developers are familiar with the standard IE conditional comments that allow you to load a stylesheet only in Internet Explorer.  For example: View the code on Gist. Many new WordPress developers / themers tend to just hardcode these conditional comments directly into their theme’s header.php file.  This approach might work well for one-off…… Read More

Reorder Posts in WordPress Programatically

WordPress uses the menu_order column in the posts table to manage the ordering of pages and hierarchical post types. If you have a situation where you need to display a collection of posts in a particular order, making use of this database column is the way to go. Then whether you are fetching posts with…… Read More

WordPress User Login Redirect

WordPress sites that offer personalized or private content typically want to keep their users on the front end of the site.  However, WordPress automatically takes users to the back end dashboard after they login.  Obviously, we need to be able to redirect these users to the front end of the site; but at the same…… Read More

Replace the WordPress Dashboard

When it comes to customizing the WordPress dashboard, you basically have two options: Customize the widgets that appear on the WordPress dashboard by adding and removing them in the code. Completely replace the dashboard with your own custom dashboard. The first option is a great option, but the issue here is that you have no…… Read More

The WP_Post Object and Virtual Properties

WordPress 3.5 introduced a lot of changes under the hood. One of the simple things that makes my life much easier is the way that the new WP_Post object allows post meta to be fetched using virtual properties. If you aren’t familiar with classes or virtual properties, all you need to know is that you…… Read More

WordPress User Last Login

Have you ever needed to know a WordPress user last login date?  By default, WordPress doesn’t provide any information on when a user last logged in.  However, such information is extremely useful when, for example, trying to delete inactive users or evaluate the success of a membership site. The User Meta API Thankfully, WordPress allows…… Read More

Check If A WordPress Plugin Is Active

If you ever have to write code that is dependent on a specific plugin being active, WordPress has you covered with the is_plugin_active() function. View the code on Gist. All you need to do is pass in the plugin basename and WordPress will do the checking to see if the plugin is active. How do you get…… Read More