WordPress CMS: Custom Fields
On a lot of my sites I use WordPress not as a blogging application but as a CMS. As I might have mentioned here before, I have worked at companies that have charged 6 figures for far less functionality in a CMS than you get completely free with WordPress, so why re-invent the wheel?
A much overlooked feature of WordPress that can add a lot of nice touches to a site is the “Custom Field” option along with custom templates.
Say you wanted to show a thumbnail photograph to go along with a blog post, but not in the article itself but alongside the headline?
Or maybe you have a site where you want to link content to a certain product, but pull in details about the product from a database or feed rather than manually type the information in over and over as product details change?
Another option might be to change the look and feel of a page away from the default, for example change the color of just that one page, or different header graphics. Sometimes people will color code so people know which section of a site they are looking at for example.
All of these can be achieved with custom fields. Custom fields are just a way that you can add a “meta” value to a page or post, that is information “about” a piece of content rather than as “part of” the content. Yes we have the option of using tags or categories, but these tend to be visible, and not as specific as we would like. Custom fields can be used to link to a product ID, ISBN number, affiliate code, or image Src without cluttering up our tag database.

In your blog post/page editing screen there is a box containing the custom field information. There is first a dropdown containing the custom fields you have used before. This might well be populated if you use any SEO based plugins. That is how the custom title, keywords and description are added to a page.
Next you have boxes where you can provide a key and a value. So your key might be “ISBN” and your value might be a particular books ISBN code.
In your template you can pull out the value belonging to a particular custom field using the following PHP code:
<?php
$custom_field = get_post_meta($post->ID, "key", $single = true);
?>
You can see this in action over at my credit card site where we pull in a single card details into a page by specifying the cards ID, in this case the Blue American Express card. All the other details are pulled from a separate database, and are refreshed from the source daily.
WordPress is much more powerful than people give it credit for. Really, I would choose it over software costing tens of thousands of dollars. You just need a little lateral thinking to make it really rock.
If you know of any innovative uses of WordPress, do share in the comments …
Related posts:
- Customize Your WordPress Admin Interface
- WordPress as a CMS
- WordPress Based Membership Site
- Crumb Trail Navigation in WordPress
- WordPress 2.5 Versus WordPress.com
Posted on February 13, 2009 by Chris Garrett
Filed Under Blogging
Comments
8 Responses to “WordPress CMS: Custom Fields”
Leave a Reply



Thanks so much for the info on Custom Fields input for WP CMS. I’m a novice at html and programming, but I’m finding my way (completely self taught). I created my whole website and another using WordPress. I agree with you wholeheartedly! It’s awesome. I think what helps me too is that I do graphic design, so I’m able to add a lot to the look and feel of the sites. I’ll have to look further to the Custom Fields thing. I currently use inline styles when I’m trying to manipulate the template in blogs or pages. It’s kind of a pain. Thanks for calling my attention to this handy tool. Now, I just need to figure out how to use it.
Got a clear idea about custom field.Don’t understand CMS.
We use custom fields as a way of storing post related information for plugins and themes. However, we don’t believe a user should be exposed to them – they’re too slow to use and too hard to remember… especially for casual users.
So instead we build the field into the edit page – makes life far simpler for the user. Yes, the budget goes up slightly, but hey – WordPress is all about being easy to use.
that looks awesome, but I am still too much of a noob to get the details. This looks like a great way to put up an affiliate link, yet those tend to be static and would not need a database. How are you controlling the size of the displayed graphic and text?
thanks, love your site
Nice post, I just finished writing my WordPress Mass Custom Fields Manager Plugin, you can get it on my blog. Please leave a feedback if you use it.
Very helpful and informative post! I’m very interested in how you use custom fields to pull data from a database to be displayed in a post or page. Could you show us the actually code that goes into the post/page to do this? Thanks.
Have you checked out the new WordPress themes from http://www.rockettheme.com? I have a developer license for Joomla, but they just added WordPress themes in October of 2009. I think that they add a lot of options for WordPress as a CMS.
[...] as a CMS platform by using custom fields: http://www.cogniview.com/convert-pdf-to-excel/post/wordpress-cms-custom-fields/ [...]