Append Items to A WordPress Nav Menu

WordPress provides a filter called wp_nav_menu_items which allows you to easily append your own list items to a menu. This allows you to do cool things like automatically append an ‘Admin’ link to the end of the footer menu. This is particularly useful when handing off a site to a client and you want to… Read More

Get All Post Types that Support a Feature in WordPress

WordPress uses post type support to make it easy to manage the feature set for custom post types. Post type support can be defined when registering a post type via register_post_type(), or after the fact via add_post_type_support(). If you would like to remove post type support, you can just use remove_post_type_support(). If you need to… Read More

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

Redirect an Old Domain to a New Domain with .htaccess

If you have decided to change your site’s domain and are hosting your old site on an Apache server, then redirecting traffic to the new site is relatively simple. The most important aspect of the move is to ensure that you don’t lose visitors and that you don’t lose any existing rankings with the search… 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

The Euclidean Algorithm in PHP

The Euclidean algorithm is a mathematical formula for efficiently determining the greatest common divisor between two integers. It is great for simplifying fractions. Yep, I can see your eyes glassing over already. If you really want to know more about this algorithm other than my code snippet, just read the about Euclid’s algorithm on Wikipedia…. Read More