I decided a couple of weeks ago that I wanted to do an ongoing tutorial series with WordPress custom fields. At first, I thought I’d simply write a complete guide, but that idea seemed daunting. It seems far easier to break down the guide into individual posts in a series. Instead of writing a general guide, I will write detailed tutorials on specific and practical uses for custom fields.
I’ve been using custom fields for various tasks on this site for a while. A few places you can see some custom field uses on this site are:
- On the ” title=”Projects Page”> Projects page, there is a list of several subpages. For each subpage, there is an image, title, and description. This list of subpages is made possible by custom fields.
These are fairly simple examples, and this tutorial series will cover more advanced uses later in the series. Mostly, I will cover what I think are practical uses of custom fields. Of course, suggestions are always welcome. So, if you want something specific, but can’t figure out how to do it, don’t hesitate to ask. This is a learning experience just as much for me as it is for you.
What are custom fields?
Custom fields are additional information that you can add to your posts and pages.
The good starting point is checking out WordPress’ Using Custom Fields. It’s a very basic tutorial, but will give you some idea of what custom fields are. The Undersigned has a good tutorial also. Neither of these tutorials cover a lot of uses, and I think that’s why many people don’t know what to do with custom fields — there are not enough detailed tutorials.
The truth is that you can do pretty much anything you want with custom fields. Your imagination is your limit.
Basic Usage:
The first thing you need to know is where to input custom fields. On “Write Page” or “Write Post” in the WordPress Dashboard, there is section at the bottom of the page that lets you input as many custom fields as you want. Here is a screenshot:
There are two different things you can input into a custom field — “Key” and “Value.” It doesn’t get much simpler than that.
What it is a Key and Value? The Key is the name of the custom field and the Value is simply the value you want to give to that name. For example, you might write book reviews and want to add some additional information like the book’s author or publisher, give it a link through your Amazon Affiliate membership, create a star rating system with images, or a multitude of other bits and pieces.
What do I do with this information? You can pull this information out in posts, on other pages, into sidebars, or wherever.
To give a list of your book reviews in alphabetical order with the author’s name, you could create a custom field with a Key named “author” and a Value of “The Author’s Name” for several posts, or reviews. After writing these reviews and putting them into your “Book Reviews” category, you would put together a page called “Book Reviews” or create a category-specific template for your “Book Reviews” category.
Here’s how you would list each book review (category=27 would need to be changed to your “Book Reviews” category ID):
<ul>
<?php
$book_reviews = get_posts('category=27&numberposts=-1&orderby=post_name&order=ASC');
foreach($book_reviews as $post) : setup_postdata($post);
?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php $author = get_post_meta($post->ID, "author", $single = true);
if($author !== '') {
echo 'by ' . $author;
} ?>
</li>
<?php endforeach; ?>
</ul>
This is pretty basic, but I hope you’re getting some kind of an idea what custom fields are and what you might can do with them. I don’t want to give too much away on the Book Review use yet because I will definitely write a full-blown tutorial on how to add cool information to reviews.
Now, that you’re warmed up a bit, stay tuned by subscribing to the feed or bookmarking this page for future reference. I will link all the articles in the custom field tutorial series for WordPress here.

great thanks a lot
great
thank you..
No problem.
thanks a lot. i´m trying to understand what this all is about. i´ve just installed the fabulous options theme (teleperra.com).
i´m following you.
cheers.
great thanks a lot
Hello
Thanks for the great tutorials.
My question is could you please write a plugin that can simply help to upload images and manage them to a specific folder withing wordpress where we can call the image files for the excerpts.
It think wordpress files upload sucks (I don’t even know if there is one beside uploading directly images for the articles.
Please help us with a plugin or guidance or how o do it withing wordpress without using any external ftp.
Again thanks and I am gonna follow this post for answer
Thanks for the tutorial!
Are there any way to add a page of custom field in admin panel?
For example,
within the theme, I use the query_posts
?php query_posts($query_string.'&posts_per_page=x'); ?>And I wish to control the x amount in the admin panel where I will create a new menu page for it.
Thanks!
thanks for the info dude…can u jus tell me how to add an adsense videounit code into the custom field??
Justin: Great article, but I’m confused. How does this code sort by the custom field? It looks like it’s sorting by “post_name” not “author”.
Any help you can provide would be appreciated!
Thanks
Steve
Thanks for your introduction on Custom Fields, a very useful and easy tool to making WordPress websites easier to update.
I have expanded on your discussion on Custom fields with a simplified tutorial at:
http://impresslab.com/2008/08/using-custom-fields-in-wordpress/
Wow Cool !
Super Man
Nice Site
this’s a very useful post – thank you for sharing!
chris
I think custom field usage in wordpress magazine and complex themes are really important. in fact it makes things really easy. Thanks for sharing this nice intro.
I am using wordpress for more than three years. But till today before seeing this post, I was completely unaware of this custom fields. I thought it might be for something like for adding keywords meta tags etc.
Thanks for enlightening on this. I’ll look up more opportunities to use the feature more productively. If I get a new idea about using this feature I’ll post in my blog.
This is a great overview for custom fields on posts and returning info in the loop.
I’ve be stumped or a while if i can use the custom fields for static pages (not posts) and then return the fields in a newly-created static page. For example, i’ve created 10 static pages, one for each type of surfboard. The keys are builder, color, type, etc. Now, I’d like to return all 10 pages in a table of contents page. How would i do this since this is outside the loop as i understand it? Sample code to drop into me index.php file would be awesome.
Thank you!!
Hey, great post! Works great but I really would like it if the list was not text links but a group of thumbnail links from one categorie. Any idea how that code would look like?
Hi – thanks for the tutorial.
New WP user here. I’m wanting to add some custom details to my post details which would be exif info for photos. I’m sure CF’s would allow me to do that – but i can’t work out how it would be coded… anyone ideas anyone?
For example:
Travel | Posted on Feb 25th by Electrique Kingdom | No comments – being my currect post details
Travel | ¹/125 sec | ƒ/5.6 | ISO 200 | Posted on Feb 25th by Electrique Kingdom | No comments – this is what i want!
Thanks for looking.
And i can not found your bbpress themes.Can u help me?
The edit post screen now refers to these as name/value, even though the wordpress documentation still refers to this a key/value. This is kind of confusing. I’m still trying to find information on how to add these custom fields into my own theme.
so you don’t call the ‘value’ in the php, you just call the ‘key’ Right?
Fantastic! Seriously out of all the custom field tutorials I have been mowing through this one finally touches on using custom fields in custom TEMPLATES. Most of the other tutorials only touch on how they can be used on the index.php page. All I wanted to do was make a simple gallery page of a certain category. And now its done, thanks!
The “What are custom fields” was a great explanation. It would be great to use custom fields as footnotes in posts. I am going to use the as “extra” info above the header. In hope it will help with sem/seo. Thank for the great toot.
I meant “use *THEM* as”. sry for the typo.
I installed the plugin and activated and I don’t see the Custom Fields box anywhere where you are suppose to select Key and Value. Is there something else I’m suppose to be doing after activating to plugin?
nice tutorial… I will implement this to my theme.. thanks mate