About me...

I'm a web designer/developer working for the NHS in Barnsley, UK.
I also dip into freelance web design work under the title base6 Design.

Twitter

Follow me on twitter

base6 Design

My freelance company

‘Custom Field Template’ Rocks!

Filed under: WordPress - October 23rd, 2008

Look at this screenshot:

Now look at the results (WP post screen):

These are from the new Custom Field Template plugin developed by Hiroaki Miyashita. Its an upgrade of the old defunked rc:customfieldgui plugin which was never upgraded to work with WP 2.5.

Why it rocks

Simple really. By adding a couple of get_post_meta tags and a few foreach loops to a WP template you can fetch back complex meta data added to any post OR page in your WP site!

For example. The above screenshot (not my own, sorry) uses a ‘Favourite Post’ checkbox. Using this, you could easily ’stick’ a post to your front page.

Also, if you have multiple fields, lets say you had 2 or 3 ‘Plan’ boxes (see screenshot) you can fill in a few ‘plans’ related to this post and bring them back using something like:

<?php

$plan = get_post_meta($post->ID, ‘Plan’);

foreach(($plan) as $plans) { echo $plans . ‘, ‘; }

?>

What this boils down to is the fact that any WP user now has a limitless number of opportunities to easily add extra meta to their posts and pages. And bringing it back isn’t too difficult either.

Real life use

This plugin made my day yesterday. I was after a way to display the colour of a bottle used in a system detailing the storage of certain liquids. Initially I added multiple categories and used the get_the_category tag to attempt to bring back a certain ‘colour’ category.

In short it didn’t work as planned. After many hours toil I was minutes away from using code from this tutorial (adding custom fields to the post screen using theme functions). Thankfully I landed on Custom Field Template just in time and had a solution in less than an hour.

YES its not perfect relying so heavily on a plugin like this. But you have to admit, its one of the best WP plugins out there. Sure kicks Flutters arse.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

copyright 2009 Michael Kimb Jones