Skip to navigation | Skip to content



Archive for the category ‘WordPress’

WordPress feeds mashup widget

I’ve put together a few little widgets in my time for client sites, dropped into my custom theme’s functions.php. I might look into putting them out there in a formalized way some time (plugins? a collection of code snippets?), but for now here’s one I just did that I think is pretty useful. It basically takes one or more feed URLs, and outputs the most recent items after merging the feeds together.

Read more »

SLT Custom Fields 0.3b

I know, I’m just rocketing through version numbers and keeping it in beta. But, the new version of my Custom Fields plugin for developers is available now.

It should work fine with any systems you’ve had the old one running on but please backup all data first, don’t use on production servers unless you’re brave, and do let me know if you find any bugs (comments here).

Read more »

WordPress Custom Fields plugin

Well, it turns out that my release of a “reloaded” version of my hugely popular custom fields theme code was a bit premature. I quickly realized that even though (or especially because) my target audience is developers, the code should become a plugin. The field definitions should be separate, in the theme, so the core plugin code can be easily update. D’uh!

So, while I’m not officially releasing the plugin yet on the WP repository, I thought I’d kick off a public beta. Check out the SLT Custom Fields plugin. Documentation is incomplete, and bugs may exist. However, all functionality seems to be working good on test sites. Use on production servers at your own risk, but please report any problems here.

I’m hoping this will grow into a powerful and stable tool for WordPress custom theme developers.

Read more »

WordPress custom fields reloaded

PLEASE NOTE: This code has now evolved into the SLT Custom Fields plugin.

My post on controlling your own WordPress custom fields is by far and away the most popular post on this site. Maybe I should monetize it or something?

Well, for a start, as a good friend once said, the word “monetize” should be take outside and shot. Besides, building WordPress sites does very well for me.

A better idea: improve the code!

Read more »

Custom fields for custom post types

I’ve just updated my most popular post, Control Your Own WordPress Custom Fields. It’s a long-overdue change, which allows for custom post types.

One thing is, as far as I can tell, when you set properties in PHP classes, you can’t use “dynamic” values. In the new version, there’s a property called $postTypes. I wanted to use get_post_types() to dynamically include public custom post types as well as the standard “post” and “page”, but I kept getting “unexpected (” errors. For now, I’ve hard-coded an array that can be added to. Does anyone know a more elegant solution? The only thing I can think of is using a method, though maybe I’m misunderstanding what I’m doing in terms of using a property.

Anyway, I’ve re-opened the comments over there, so do chip in with ideas!

Widget Logic code generator

Over at the wordpress.org support forums I’ve just posted a useful little snippet for easily generating code for the Widget Logic plugin. I thought it was most appropriate over there with the widget-logic tag. Head over, try the code, and join in the discussion if you’ve any suggestions or ideas!

WordPress Media Library URLs

Many, many times in my custom WordPress development, there are situations where I have to ask clients to grab the URL for an image from the Media Library. Maybe to paste into a widget or a custom field? In any case, to get the URL of the file, by default in WP you have to edit the media first—you get a read-only input called File URL.

Wouldn’t it be easier if the URL was output in the main list? I posted some code here a while ago to do this. But what if you want to make the URLs for all the different sizes of images in the Media Library available? I thought I’d revamp my code to tackle this and post it afresh here.

Read more »

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 »