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 Reading page, you can see all of my book reviews pulled into a nice organized list. Under each book’s title is the author’s name.
- My 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.




[...] “Custom Fields” are a powerful part of Wordpress. Here’s a brief introduction. [...]
[...] Tadlock wrote a whole series about using custom fields, which I’ve definitely got to take a closer look at when I have time, and one of these posts [...]
[...] specifically, the Using Custom Fields page and the the_meta function. There’s also a nice run through of an implementation here and here. Popularity: unranked [...]
[...] Wordpress Custom Fields 系列教程justintadlock.comCdrPlum æäº¤äºŽ æ•°ç§’ ä¹‹å‰ [...]
[...] – Read: http://codex.wordpress.org/Using_Custom_Fields – WordPress custom field guide. – Read: …using-wordpress-custom-fields-introduction – my personal tutorial on custom [...]
[...] before. – Read: Using Custom Fields « WordPress Codex – WordPress custom field guide. – Read: Using WordPress Custom Fields: Introduction: Using WordPress Custom Fields tutorial series – my personal tutorial on custom [...]
[...] Using WordPress Custom Fields tutorial series – [...]
[...] knowledgeable on the subject. One more thing I may suggest ATM is looking at this basic tutorial: Using WordPress Custom Fields: Introduction: Using WordPress Custom Fields tutorial series This quote from the article *might* be able to apply to what you want: [...]
[...] understanding of WordPress, themes, and php in general. In fact, in going through his custom field tutorial, I was even inspired to make a couple of custom sidebar widgets for this theme using his [...]
[...] to learn more about this powerful and underutilized function of WordPress. Justin has a great tutorial on getting started with custom fields. Thomas Silkjær also has a brief tutorial on his site that [...]
[...] It has a bit of a web-magazine look about it – with a slick YouTube video in the sidebar, and post highlights using custom fields. [...]
[...] 1)Using WordPress Custom Fields: Introduction- An ongoing tutorial series for practical uses of WordPress custom fields [...]
great thanks a lot
great
thank you..
No problem.
[...] 1)Using WordPress Custom Fields: Introduction- An ongoing tutorial series for practical uses of WordPress custom fields [...]
[...] 1)Using WordPress Custom Fields: Introduction- An ongoing tutorial series for practical uses of WordPress custom fields [...]
[...] Tutorial series on using custom fields. [...]
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.
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
great thanks a lot
[...] Usando los “Custom Fields” del panel de escritura [...]
[...] Применение WordPress Custom Fields (дополнительные поля) [...]
[...] at wp has a tutorial on the subject and I’ve seen several other good ones, my favorite being Justin Adlock’s introduction to custom [...]
[...] Using WordPress Custom Fields [...]
[...] Usando los “Custom Fields” del panel de escritura [...]
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
[...] Usando los “Custom Fields” del panel de escritura [...]
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!
[...] You know how to use WordPress custom fields, don’t you? If you don’t, check this series of posts at Justin Tadlock’s blog. [...]
thanks for the info dude…can u jus tell me how to add an adsense videounit code into the custom field??
[...] 28. Using WordPress Custom Fields [...]
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
[...] Using WordPress Custom Fields [...]
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/
[...] 28. Using WordPress Custom Fields [...]
[...] 28. Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields: Introduction If you’re not familiar with using custom fields, this is a good place to start. [...]
[...] Using WordPress Custom Fields: Introduction If you’re not familiar with using custom fields, this is a good place to start. [...]
[...] Using WordPress Custom Fields: Introduction [...]
[...] Using WordPress Custom Fields: Introduction If you’re not familiar with using custom fields, this is a good place to start. [...]
Wow Cool !
Super Man
Nice Site
[...] here’s how you would pull the data from a custom field where the key = image and use the value of that field [...]
[...] 1)Using WordPress Custom Fields: Introduction-这是一个系列教程,通过一些实际演示教你如何更好的使用Wordpress的自定义字段功能 [...]
[...] Using WordPress Custom Fields: Introduction [...]
[...] A Custom Fields Tutorial Series at justintadlock.com [...]
[...] 1)Using WordPress Custom Fields: Introduction-这是一个系列教程,通过一些实际演示教你如何更好的使用Wordpress的自定义字段功能 [...]
[...] will assume that you know how to use custom fields (if not look here and here), so for each page we are going to include on our menu – add a custom field with a key of subtitle. [...]
[...] 28.使用WordPress自定区域 [...]
this’s a very useful post – thank you for sharing!
chris
[...] If you aren’t familiar with custom fields, then go read about custom fields from either the Wordpress Codex or in a better explained version by Justin Tadlock. [...]
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.
[...] 28.使用WordPress自定区域 [...]
[...] Using WordPress Custom Fields [...]
[...] explain how to add images to your posts using WordPress custom fields. It is the third part of the Using WordPress Custom Fields Series. This tutorial assumes you at least know what XHTML, PHP, CSS, and WordPress are. Plus, you should [...]
[...] 26.在第一篇WordPress日志中展示Google广告优秀的SEO(搜索引擎优化)站点会告诉你,把广告放在你第一篇日志的下方会非常有效。27.为不同的分类创造不同的单独日志页面能为你发表到WordPress博客不同分类的文章定制各自特定的样式。28.使用WordPress自定区域你能在WordPress的自定区域里放置几乎任何你想要的东西。唯一能限制你的是你的想象力。29.生成数据存档目录将你的每一篇日志整理到数据存档目录中,如此安排以便整理过去博客发表的日志。30.简单一部搞定WordPress文章存档为扫描装置提供特别准备的文章存档显示。31.在侧边栏显示登陆框在你的WordPress博客首页侧边栏增加一个用户登录框。 [...]
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.
[...] 使用wordpress自訂欄位 透過自訂欄位,你可以做很多你想要的有趣功能 [...]
And i can not found your bbpress themes.Can u help me?
[...] explain how to add images to your posts using WordPress custom fields. It is the third part of the Using WordPress Custom Fields Series. This tutorial assumes you at least know what XHTML, PHP, CSS, and WordPress are. Plus, you should [...]
[...] 108. Using WordPress Custom Fields: Introduction [...]
[...] Using WordPress Custom Fields: Introduction [...]
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.
[...] 53. Using WordPress Custom Fields [...]
[...] 25. WordPress özel alanları (custom fields) kullanma [...]
[...] Using WordPress Custom Fields: Introduction [...]
[...] 能为你发表到WordPress博客不同分类的文章定制各自特定的样式。 28.使用WordPress自定区域 [...]
so you don’t call the ‘value’ in the php, you just call the ‘key’ Right?
[...] 9. Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields: Introduction [...]
[...] 9. Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
[...] 28.使用WordPress自定区域 [...]
[...] A simple introductions to the WordPress Custom Fields [...]
[...] Usando los “Custom Fields” del panel de escritura [...]
[...] and have a lot of different applications. If you’d like to read an overview of the concept, Justin Tadlock explains it pretty [...]
[...] Using WordPress Custom Fields [...]
[...] 28.使用自定区域Wordpress [...]
[...] 53. Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
[...] Campos personalizados: como adicionar informações extras, na hora de cadastrar posts, páginas ou usuários; [...]
[...] You know how to use WordPress custom fields, don’t you? If you don’t, check this series of posts at Justin Tadlock’s blog. [...]
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields [...]
[...] Usando los “Custom Fields” del panel de escritura [...]
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields: Introduction If you’re not familiar with using custom fields, this is a good place to start. [...]
[...] Using WordPress Custom Fields [...]
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!
[...] Using WordPress Custom Fields [...]
[...] Using WordPress Custom Fields: Introduction Share this post! Twitter Digg Facebook Delicious StumbleUpon Google Bookmarks LinkedIn Technorati Favorites This entry was posted on 2009年11月2日 at 2:30 下午, and is filed under PW主题. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. [...]
[...] Using WordPress Custom Fields: Introduction [...]
[...] Usando los “Custom Fields” del panel de escritura [...]
[...] Custom fields, on the other hand, allow me to keep the post title simple (in this case, just the course title) and offer many options for how to display other pieces of information, as well as options for sorting and filtering posts based on the fields. If you are unfamiliar with custom fields, Justin Tadlock has an excellent introduction. [...]
[...] Modslider has a built-in HD video player that plays FLV video files. You are no longer restricted to pixelated YouTube videos. To add a video, upload the FLV file to your server using your favorite method, like FTP. Copy and paste the link to the file into a custom field called video. Next, add a video thumbnail. You can do this the exact way that you add regular thumbnails, except, you will want to add an image large enough to fit the maximum size of the video player, for best results try an image that is 950px wide. Add the video thumbnail to a custom field with key value video-thumb. For multiple videos within a post or page, try different values for the same video key which mean you can have 2 or more instances of video key. Same goes for video-thumb. Note that each thumbnail should be in the same precedence as that of video for them to match. You can also add other multimedia, which can include virtually any media with embed capabilities. Enter “multimedia” as the key value and paste your YouTube, Vimeo, or any other html embed code into the value field. You can read more about using custom fields here. [...]
[...] domain name106. How to Make a Control Panel for Your WordPress Theme107. Wordpress as a CMS108. Using WordPress Custom Fields: Introduction109. WordPress Custom Fields: Laying Text Over Your Lead Graphic110. How to setup PrettyURLs on [...]
[...] 53. Using WordPress Custom Fields Introduction [...]