WP-Mix

A fresh mix of code snippets and tutorials

Display a custom gravatar in WordPress

Using your own custom gravatars (aka avatars) in WordPress is a piece of cake.

Note about date and time

Just a quick note about how WordPress handles dates and times.

Display all comments on separate page

Normally WordPress themes display comments on the same post or page. WordPress makes it possible to page the comments, so that there are only so many per page, but by default it’s not possible to display all comments on a separate page. Here’s how to do it in three easy steps.

Remove the date from WordPress permalinks

With the rise of the “short URL”, including the date in URLs is no longer considered “cool”, so you may want to “get with it” and dumb down your WordPress URLs to make them shorter. Here is how to use .htaccess to remove the date from your WordPress permalinks.

Query custom post types

Here’s how to query custom post types with WordPress 3 and better.

Publish a post via functions.php

Normally users create new posts from the Posts Edit screen in the WordPress Admin, but you can also publish posts from the functions.php file.

Disable theme switching

By default WordPress enables users to switch themes while working in the Admin area. Sometimes a user might screw this up and accidentally activate the wrong theme.

WordPress navigation outside the loop

Normally the template tags used for navigating posts and pages must be included inside of the WordPress loop. This is great but there may be times when you need to display the navigation links outside of the loop.

Display user-friendly dates and times

Normally WordPress displays dates using boring old numbers. How much more fun would it be to display dates and times using human-readable language to make them all user-friendly and swell.

Display a number for each post

To display an auto-incrementing number for each post, add the following snippet to your theme’s functions.php file:

Increase upload limits for WordPress

If you’re encountering restrictive upload limits in WordPress, here is a simple fix:

Remove sub-menus

Quick snippet for removing or disabling WordPress sub-menus: