Skip to navigation | Skip to content



Archive for August 2010

Get a number of posts with optional sticky posts at the top

I’ve not really used sticky posts in WordPress. I’ve just been hacking around to try and use this system instead of my own custom field checkbox for “featuring” posts. There’s some definite pros: the user can toggle the status via the Quick Edit feature instead of having to edit the whole post. There’s also some cons: the sticky posts system has some quirks which, while understandable, limit it slightly.

One niggle is that sticky posts in standard post loops only really impact things (i.e. bubble to the top) when is_home() is true. The real killer is that when you’re only outputting a certain number of posts, using, say, get_posts and the numberposts argument, if there are sticky posts, you’ll get the sticky posts plus the number of posts you specify from the rest of the posts. So if you ask for 3 posts and there’s 1 sticky post, you’ll get 4 posts in total. Grrr!

This is acknowledged in a couple of trac tickets. There are reasons for this—it’s a feature, not a bug, as they say—but what do you do if want to do things your way?

Read more »

Using WordPress 3.0 custom menus for custom stuff

The introduction of custom menus in WordPress 3.0 was very welcome. They can be a bit baffling at first (see the ever-reliable Justin Tadlock’s guide if you’re confused), but they’re a great CMS addition to WP.

Here I want to detail a couple of tips for going beyond the standard usage.

Read more »

Customize the WordPress admin menus

NOTE: Forget these workarounds! We’ve now got core functions to do the trick :) Check out Justin Tadlock’s tutorial on using them.

Also, to disable theme and plugin editing, don’t just remove the menu links. You can use a constant in wp-config.php to completely switch that functionality off.

I’ve recently been looking at de-cluttering the WordPress admin interface. There’s some good plugins for this, such as Adminimize, WP-CMS Post Control (for hiding boxes on the post screen, according to user role) and White Label CMS (for extensive customization of logos, menus, etc.).

As ever, I’m also interested in getting just a particular aspect working with a bit of theme code—if only one aspect is needed, it’s sometimes nice to drop it into the theme and have one less plugin loading. The aspect I’m thinking of here is removing a few menu items.

So, with the usual caveat that this is code for theme developers, to be dropped into the active theme’s functions.php file, and a nod to hungred.com for initial inspiration, here goes.

Read more »

View complete archives »