Menu Search
Jump to the content X X
Smashing Conf Barcelona

You know, we use ad-blockers as well. We gotta keep those servers running though. Did you know that we publish useful books and run friendly conferences — crafted for pros like yourself? E.g. our upcoming SmashingConf Barcelona, dedicated to smart front-end techniques and design patterns.

Custom Fields Hacks For WordPress

In our previous articles on WordPress hacks, we discussed the incredible flexibility of WordPress, which is one of the biggest reasons for its popularity among bloggers worldwide. Custom fields in particular, which let users create variables and add custom values to them, are one of the reasons for WordPress’ flexibility.

You may also be interested in the following related posts:

In this article, we’ve compiled a list of 10 useful things that you can do with custom fields in WordPress. Among them are setting expiration time for posts, defining how blog posts are displayed on the front page, displaying your mood or music, embedding custom CSS styles, disabling search engine indexing for individual posts, inserting a “Digg this” button only when you need it and, of course, displaying thumbnails next to your posts

1. Set An Expiration Time For Posts Link

Image source: Richard Vantielcke5

The problem. Sometimes (for example, if you’re running a contest), you want to be able to publish a post and then automatically stop displaying it after a certain date. This may seem quite hard to do but in fact is not, using the power of custom fields.

The solution. Edit your theme and replace your current WordPress loop with this “hacked” loop:

if (have_posts()) :
     while (have_posts()) : the_post(); ?>
         $expirationtime = get_post_custom_values('expiration');
         if (is_array($expirationtime)) {
             $expirestring = implode($expirationtime);

         $secondsbetween = strtotime($expirestring)-time();
         if ( $secondsbetween > 0 ) {
             // For example...

To create a post set to expire at a certain date and time, just create a custom field. Specify expiration as a key and your date and time as a value (with the format mm/dd/yyyy 00:00:00). The post will not show up after the time on that stamp.

Code explanation. This code is simply a custom WordPress loop that automatically looks to see if a custom field called expiration is present. If one is, its value is compared to the current date and time.

If the current date and time is equal to or earlier than the value of the custom expiration field, then the post is not displayed.

Note that this code does not remove or unpublish your post, but just prevents it from being displayed in the loop.


2. Define How Blog Posts Are Displayed On The Home Page Link


The problem. I’ve always wondered why 95% of bloggers displays all of their posts the same way on their home page. Sure, WordPress has no built-in option to let you define how a post is displayed. But wait: with custom fields, we can do it easily.

The solution. The following hack lets you define how a post is displayed on your home page. Two values are possible:

  • Full post
  • Post excerpt only

Once more, we’ll use a custom WordPress loop. Find the loop in your index.php file and replace it with the following code:

<?php if (have_posts()) :
    while (have_posts()) : the_post();
         $customField = get_post_custom_values("full");
         if (isset($customField[0])) {
              //Custom field is set, display a full post
         } else {
              // No custom field set, let's display an excerpt

In this code, excerpts are displayed by default. To show full posts on your home page, simply edit the post and create a custom field called full and give it any value.

Code explanation. This code is rather simple. The first thing it does is look for a custom field called full. If this custom field is set, full posts are displayed. Otherwise, only excerpts are shown.


3. Display Your Mood Or The Music You’re Listening To Link


The problem. About five or six years ago, I was blogging on a platform called LiveJournal. Of course it wasn’t great as WordPress, but it had nice features that WordPress doesn’t have. For example, it allowed users to display their current mood and the music they were listening to while blogging.

Even though I wouldn’t use this feature on my blog, I figure many bloggers would be interested in knowing how to do this in WordPress.

The solution. Open your single.php file (or modify your index.php file), and paste the following code anywhere within the loop:

$customField = get_post_custom_values("mood");
if (isset($customField[0])) {
    echo "Mood: ".$customField[0];

Save the file. Now, when you write a new post, just create a custom field called mood, and type in your current mood as the value.

Code explanation. This is a very basic use of custom fields, not all that different from the well-known hack for displaying thumbnails beside your posts’ excerpts on the home page. It looks for a custom field called mood. If the field is found, its value is displayed.


4. Add Meta Descriptions To Your Posts Link


The problem. WordPress, surprisingly, does not use meta description tags by default.

Sure, for SEO, meta tags are not as important as they used to be. Yet still, they can enhance your blog’s search engine ranking nevertheless.

How about using custom fields to create meta description tags for individual posts?

The solution. Open your header.php file. Paste the following code anywhere within the <head> and </head> tags:

<meta name="description" content="
<?php if ( (is_home()) || (is_front_page()) ) {
    echo ('Your main description goes here');
} elseif(is_category()) {
    echo category_description();
} elseif(is_tag()) {
    echo '-tag archive page for this blog' . single_tag_title();
} elseif(is_month()) {
    echo 'archive page for this blog' . the_time('F, Y');
} else {
    echo get_post_meta($post->ID, "Metadescription", true);

Code explanation. To generate meta descriptions, this hack makes extensive use of WordPress conditional tags to determine which page the user is on.

For category pages, tag pages, archives and the home page, a static meta description is used. Edit lines 3, 7 and 9 to define your own. For posts, the code looks for a custom field called Metadescription and use its value for the meta description.



The problem. Many bloggers have asked me the following question: “How can I link directly to an external source, rather than creating a post just to tell visitors to visit another website?”

The solution to this problem is to use custom fields. Let’s see how we can do that.

The solution. The first thing to do is open your functions.php file and paste in the following code:

function print_post_title() {
  global $post;
  $thePostID = $post->ID;
  $post_id = get_post($thePostID);
  $title = $post_id->post_title;
  $perm  = get_permalink($post_id);
  $post_keys = array(); $post_val  = array();
  $post_keys = get_post_custom_keys($thePostID);

  if (!empty($post_keys)) {
      foreach ($post_keys as $pkey) {
          if ($pkey=='url1' || $pkey=='title_url' || $pkey=='url_title') {
              $post_val = get_post_custom_values($pkey);
      if (empty($post_val)) {
          $link = $perm;
      } else {
          $link = $post_val[0];
  } else {
      $link = $perm;
  echo '<h2><a href="'.$link.'" rel="bookmark" title="'.$title.'">'.$title.'</a></h2>';

Once that’s done, open your index.php file and replace the standard code for printing titles…

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

… with a call to our newly created print_post_title() function:

<?php print_post_title() ?>

Now, whenever you feel like pointing one of your posts’ titles somewhere other than your own blog, just scroll down in your post editor and create or select a custom key called url1 or title_url or url_title and put the external URL in the value box.

Code explanation. This is a nice custom replacement function for the the_title() WordPress function.

Basically, this function does the same thing as the good old the_title() function, but also looks for a custom field. If a custom field called url1 or title_url or url_title is found, then the title link will lead to the external website rather than the blog post. If the custom field isn’t found, the function simply displays a link to the post itself.


6. Embed Custom CSS Styles Link


The problem. Certain posts sometimes require additional CSS styling. Sure, you can switch WordPress’ editor to HTML mode and add inline styling to your post’s content. But even when inline styling is useful, it isn’t always the cleanest solution.

With custom fields, we can easily create new CSS classes for individual posts and make WordPress automatically add them to the blog’s header.

The solution. First, open your header.php file and insert the following code between the <head> and </head> HTML tags:

<?php if (is_single()) {
    $css = get_post_meta($post->ID, 'css', true);
    if (!empty($css)) { ?>
        <style type="text/css">
        <?php echo $css; ?>
    <?php }
} ?>

Now, when you write a post or page that requires custom CSS styling, just create a custom field called css and paste in your custom CSS styling as the value. As simple as that!

Code explanation. First, the code above makes sure we’re on an actual post’s page by using WordPress’ conditional tag is_single(). Then, it looks for a custom field called css. If one is found, its value is displayed between <style> and </style> tags.


7. Re-Define The <title> Tag Link


The problem. On blogs, as on every other type of website, content is king. And SEO is very important for achieving your goals with traffic. By default, most WordPress themes don’t have an optimized <title> tag.

Some plug-ins, such as the well-known “All in One SEO Pack,” override this, but you can also do it with a custom field.

The solution. Open your header.php file for editing. Find the <title> tag and replace it with the following code:


<?php if (is_home () ) {
} elseif ( is_category() ) {
    single_cat_title(); echo ' - ' ; bloginfo('name');
} elseif (is_single() ) {
    $customField = get_post_custom_values("title");
    if (isset($customField[0])) {
        echo $customField[0];
    } else {
} elseif (is_page() ) {
    bloginfo('name'); echo ': '; single_post_title();
} else {
} ?>

Then, if you want to define a custom title tag, simply create a custom field called title, and enter your custom title as a value.

Code explanation. With this code, I have used lots of template tags to generate a custom <title> tag for each kind of post: home page, page, category page and individual posts.

If the active post is an individual post, the code looks for a custom field called title. If one is found, its value is displayed as the title. Otherwise, the code uses the standard single_post_title() function to generate the post’s title.


8. Disable Search Engine Indexing For Individual Posts Link


The problem. Have you ever wanted to create semi-private posts, accessible to your regular readers but not to search engines? If so, one easy solution is to… you guessed it! Use a custom field.

The solution. First, get the ID of the post that you’d not like to be indexed by search engines. We’ll use a post ID of 17 for this example.

Open your header.php file and paste the following code between the <head> and </head> tags:

<?php $cf = get_post_meta($post->ID, 'noindex', true);
    if (!empty($cf)) {
    echo '<meta name="robots" content="noindex"/>';

That’s all. Pretty useful if you want certain info to be inaccessible to search engines!

Code explanation. In this example, we used the get_post_meta() function to retrieve the value of a custom field called noindex. If the custom field is set, then a <meta name=”robots” content=”noindex”/> tag is added.


9. Get Or Print Any Custom Field Value Easily With A Custom Function Link


The problem. Now that we’ve shown you lot of great things you can do with custom fields, how about an automated function for easily getting custom fields values?

Getting custom field values isn’t hard for developers or those familiar with PHP, but can be such a pain for non-developers. With this hack, getting any custom field value has never been easier.

The solution. Here’s the function. Paste it into your theme’s functions.php file. If your theme doesn’t have this file, create it.

function get_custom_field_value($szKey, $bPrint = false) {
  global $post;
  $szValue = get_post_meta($post->ID, $szKey, true);
  if ( $bPrint == false ) return $szValue; else echo $szValue;

Now, to call the function and get your custom field value, use the following code:

<?php if ( function_exists('get_custom_field_value') ){
        get_custom_field_value('featured_image', true);
} ?>

Code explanation. First, we use the PHP function_exists() function to make sure the get_custom_field_value function is defined in our theme. If it is, we use it. The first argument is the custom field name (here, featured_image), and the second lets you echo the value (true) or call it for further PHP use (false).


10. Insert A “Digg This” Button Only When You Need It Link


The problem. To get traffic from well-known, a good idea is to integrate its “Digg this” button into your posts so that readers can contribute to the posts’ success.

But do all of your posts need this button? Definitely not. For example, if you write an announcement telling readers about improvements to your website, submitting the post to Digg serves absolutely no value.

The solution. Custom fields to the rescue once again. Just follow these steps to get started:

  1. Open your single.php file and paste these lines where you want your “Digg this” button to be displayed:
    <?php $cf = get_post_meta($post->ID, 'digg', true);
      if (!emptyempty($cf)) {
      echo '" type="text/javascript">'} ?>
  2. Once you’ve saved the single.php file, you can create a custom field called digg and give it any value. If set, a Digg button will appear in the post.

Code explanation. This code is very simple. Upon finding a custom field called digg, the code displays the “Digg this” button. The JavaScript used to display the “Digg this” button is provided by Digg itself.

Bonus: Display Thumbnails Next To Your Posts Link


The problem Most people knows this trick and have implemented it successfully on their WordPress-powered blogs. But I figure some people still may not know how to display nice thumbnails right next to the posts on their home page.

To view examples of this well-known trick, visit my blogs WpRecipes17 and Cats Who Code18.

The solution.

  1. Start by creating a default image in Photoshop or Gimp. The size in my example is 200×200 pixels but is of course up to you. Name the image default.gif.
  2. Upload your default.gif image to the image directory in your theme.
  3. Open the index.php file and paste in the following code where you’d like the thumbnails to be displayed:
    <?php $postimageurl = get_post_meta($post->ID, 'post-img', true);
    if ($postimageurl) {
          <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="Post Pic" width="200" height="200" /></a>
    <?php } else { ?>
          <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php bloginfo('template_url'); ?>/images/wprecipes.gif" alt="Screenshot" width="200" height="200" /></a>
    <?php } ?>
  4. Save the file.
  5. In each of your posts, create a custom field called post-img. Set its value as the URL of the image you’d like to display as a thumbnail.

Code explanation The code looks for a custom field called post-img. If found, its value is used to display a custom thumbnail.

In case a post-img custom field is not found, the default image is used, so you’ll never have any posts without thumbnails.

More Custom Field Resources Link

  • Add Thumbnails to WordPress with Custom Fields19
    A very detailed article about adding thumbnails to your posts with custom fields. A great follow-up to the last hack we showed!
  • How to Use WordPress Custom Fields20
    Want to know more about custom fields? Then this article is definitely for you.
  • Creating Custom Write Panels in WordPress
    A very detailed tutorial on creating custom write panels in WordPress using custom fields.
  • Custom Shortcodes21
    A cool WordPress plug-in for managing custom fields using the insert shortcodes.
  • More Fields
    The More Fields plug-in allows you to create more user-friendly custom fields. Definitely interesting for when you create WordPress-powered websites for clients!


Footnotes Link

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21

↑ Back to top Tweet itShare on Facebook

This guest post was written by Jean-Baptiste Jung, a 28-year-old blogger from Belgium, who blogs about Web Development on Cats Who Code, about WordPress at WpRecipes and about blogging on Cats Who Blog . You can stay in touch with Jean by following him on Twitter.

  1. 1

    Liam McCabe

    May 13, 2009 1:33 am

    Wow some useful stuff :)

  2. 2

    Quakeulf >:3

    May 13, 2009 1:38 am

    Doesn’t the newest version of WP do some of this by default already? I think 2.7.* and above have added some extra functionality regarding post display, but I could be wrong. :3

    Nice cat btw, cute little :3 mouth it has. :3

  3. 3

    Good list. Some of them can be very useful. Keep up the good work.

  4. 4

    I use custom fields on my site for multiple purposes:
    – linking to different sources
    – meta descriptions
    – geo-locations (area / street / places, which i can use for Google Maps)
    – embed videos from different sources and display them always on the same place on a post page.

  5. 6


    May 13, 2009 1:46 am

    Still learning PHP. I like WordPress Platform to do PHP programming. Lots of plugin some more.

  6. 7

    Well it will be nice to notice that you used one of my photograph to illustrate this article without my consent.

    (SM) Sorry for inconvenience, Riri. We added the link now. And we’ll explicitly point our writers to the image credit issues. Thank you.

  7. 8

    I like wordpress, but i am also a good developer. Any application, program, script etc that needs so much hack is NOT an extensible program. WordPress has too much down sides. Definatly the best blogging tool, but WP is putting its users on a one-way track. Too few built-in extensible options. I hope WP devs will include more customizable options in 3.x versions.

  8. 9

    wawooo… this is something what i have been looking for :) thanks a lot

  9. 10

    Richard S Davies

    May 13, 2009 3:08 am

    Can’t a lot of these be done with the default WP functionality, or some plugins, like All in One SEO.

    • 11

      I mean like this: $out = . . $title . . .attribute_escape($value). . . // switchEditors.go( $name’); ;

  10. 12

    Wow perfect timing! I was just looking for a good tutorial on integrating the thumbnails next to my post deal. Thanks a bunch.

  11. 13

    Vanilla Man

    May 13, 2009 3:33 am

    This is definitely great collection of custom fields tricks! Thanks a lot!

  12. 14


    May 13, 2009 3:50 am

    Great post, I always have problems with my Digg button though? I can only get it to display top left, which then throws out the image if there is one?

    Does anyone know a way round this please? .


  13. 15

    Great post !

    Very useful ideas.


  14. 16

    Great Article, Nice tricks, I like the custom CSS one most.
    Thanks, I enjoyed this article and i like your blog

  15. 17

    Tom Bradshaw

    May 13, 2009 4:08 am

    Really useful post, thanks alot!

  16. 18

    I use this nice little plugin to expire posts on several of my WP sites:

  17. 19

    Chris Wallace

    May 13, 2009 4:58 am

    #10 should be used more often. Nobody wants to digg a post about your cat peeing on you while you are sleeping.

  18. 20

    A little confused by #2 – I thought this functionality was already included in WP by using the -More- tag? Same for the bonus hack… I can upload an image and display it already in WP. Though I suppose the hack may cut down on some time.

  19. 21

    Ferran Riera

    May 13, 2009 5:06 am

    I think that flutter is another good option to use custom fields

  20. 22

    2nd and 4th points are useful..thanks

  21. 23

    Can anyone help me? I’m searching for something, that can generate a tweet from bottom up – rotated for 90 degrees. Does this sound familiar to someone? Thx…

  22. 24

    I’m having problems implementing the BONUS code to place images next to the post. I placed the code where I wanted the image to display, but the post keeps getting bumped down. I can’t get them to display next to each other. Any advice?


  23. 25

    Great stuff, thanks.

  24. 26

    AWESOME! Just what i needed thanks guys :)

  25. 27

    Syed Balkhi

    May 13, 2009 6:48 am

    Please recheck your Digg Custom field option. I don’t think that works. Just tried and it gave me a syntax error.

    (SM) Sorry, and thank you for your comment. The script should be working now!

  26. 28

    Pretty awesome what you can do with the custom fields. This really unleashed the power of WordPress.

  27. 29

    Fabulous post! Bookmarked and saved.

  28. 30

    This article demonstrates why WP is just a blogging platform. Many people try to push it as a bona fide CMS, which it is not. However, a top-notch CMS like Joomla, already has most, if not all, of the items in this list as part of its function. No need for code hacks that may or may not work with the next update like WP.

  29. 31

    Erik Gyepes

    May 13, 2009 10:48 am

    Great article, however I would also appreciate how to use custom fields with – more custom TinyMCE editors. I know that there is plugin for it – Custom Field Template, but it has problems when multiple WYSIWYG editors are used together.

    It is very useful, especially if you design a WP template that is more like a CMS and you need more editable fields etc.

    Maybe a topic for another SM article? :)

  30. 32

    has anyone encountered a problem using Custom Fields while the Podpress plugin is installed? Apparently Podpress inserts some Error message as Meta data (via the custom field DIV)? does anyone know anything about this, or how to fix it?

  31. 33

    Chris Robinson

    May 13, 2009 11:11 am

    Nothing really new here, would like to see some more advanced WordPress tricks and hacks

  32. 34

    I tried the code in single.php but I did not know where in the sheet to put it. I typed it in the middle but did not end up working. Please help.

  33. 35

    Useful article. Thanks.

  34. 36

    this is one kick butt post!, bookmarked for sure.. and recommended!

  35. 37

    Great collection. I never started a blog in wordpress honestly… But this can break the wall.

    Oh – there´s a little error in the sixth example in line 3.
    if (!emptyempty($css)) { ?>
    should be
    if(!(empty($css))) { ?>

  36. 38


  37. 39

    I have use 3 tips out of 10 but all can be use place to place as they required

  38. 40

    Excellent Post!!! Thank you very much.

  39. 41

    Acketon Design Studio

    May 13, 2009 10:26 pm

    love this post, will come in handy building wordpress site’s for clients

  40. 42

    Thanks for the link.


  41. 43

    Peach -

    May 13, 2009 11:54 pm

    Dude, if you have complex needs like custom fields or conditional theming, just install Drupal with CCK. There’s a perfect tool for everything and WordPress is perfect for simple blogs, not so much for more advanced setups.

  42. 44

    very nice job Baptiste , thank you

  43. 45

    I just want to say, Smashing magazine, thanx for all the great posts!

  44. 46

    Jared Heinrichs

    May 14, 2009 4:28 am

    What do you use to post your php code? I love the fact that it shows it all formated. It’s also got line numbers. Sorry if this was off topic ;) Thanks in advance.


  45. 47

    ty Jean!

  46. 48

    I heart smashing magazine

  47. 49

    Edmund Blackadder

    May 14, 2009 6:43 am

    I’m still wondering why there seems to be no subscribe option for comments here. It would make our lives a lot easier (and make so much more sense) if you could subscribe to the comments of articles you have commented on. How is a conversation going to be maintained otherwise? Am I going to re-check dozens of articles after I have commented on them months ago? Not likely. Which means that anyone who has asked for help may not get it, or, perhaps worse, may not know when they do get it… Come on SM! Sort it out!

  48. 50

    Great post! This is one of my favourite sites by far.

  49. 51

    Mansoor Ehsan

    May 14, 2009 9:02 pm

    the previous version of wordpress hacks was real good. this time it was okay!

  50. 52

    Very interesting

  51. 53

    ariel sommeria

    May 15, 2009 3:40 am

    Since wordpress is well known and extensible, there are also 3rd party apps that use custom fields. For example silex( can be used as a Flash front end for WordPress using custom fields.

  52. 54

    Just wanted to let you know there is one error in the code for #6. You forgot to include the slash in the closing ‘style’ tag (Line #6).

    Otherwise, this article really helped me this morning with a new WordPress blog I’m creating. Thanks!

  53. 55

    The ‘noindex’ code doesn’t work as expected. First of all, it contains the same error as the ‘css’ code: if (!emptyempty instead of if(!(empty( . Secondly, the noindex tags also get included in the home page (in my case, the post I want to hide is the topmost on the homepage, that might have something to do with it). This hides your entire blog from Google, that’s a little too rigorous for my liking.

  54. 56

    Great, great list.

  55. 57

    Oren Yomtov

    May 19, 2009 1:25 am

    I just made a WordPress Mass Custom Fields Manager Plugin, you can get it on my blog. Please leave a feedback if you use it.

  56. 58

    TJ @ Smart Blog Tips

    May 19, 2009 10:11 am

    Thanks for such a lovely post. Would implement some of it for sure.


  57. 59

    thanks for sharing information!

  58. 60


    where is the COde for the Bonus Hack? Displaying Thumbs right next to the post … :(
    I mean the last one

  59. 61

    it’s a life saving page. I would like to ask you how to make my post/page no follow through custom field. Can i make it like there will be a custom field name ‘robots’ and the value i will change everytime to dofollow or nofollow. Please give your valuable comment.

  60. 62

    I love these ideas. Definitely bookmarked it

  61. 63

    dustin Glasscoe

    September 9, 2009 9:33 am

    Get tips! I am pulling my hair out to customize my Page Titles… I have tried and retried everything I know for 6 hours now…

    I am wanting to use a custom field per “Page” and have that field be the “Title.”

    I have attempted to edit the “Re-Define The Tag” code until I can take it no longer… and surprisingly there are no blogs about this – they all deal with Post titles….?

    Any idea how to set a custom field on the page level to rewrite the title?


  62. 64

    Canada Web Solutions Provider

    September 12, 2009 9:40 pm

    nice post…

    I’m looking for this to implement it on our new project.. found it here.. again…

    Smashing magazine is great place to look for wordpress stuff… i was looking for displaying just excerpt on home page.. but didn’t figured how can i set this..

    Using shortcodes for this is just fine.. i’m now modifying my theme…

    thanks for this…

    great post.. keep posting

    Quick Link Now
    Canada Wed Solutions Provider

  63. 65

    In case no one knew this… WORDPRESS absolutely sucks! It is the worst ^%$@#$ blog system ever created! It takes twice as long to setup, it is extremely difficult to customize and update, you CANNOT insert features or modify and it requires all kinds of insane plugins for basic functionality and did I mention it sucks!?? That idiot Matt McGyver, or whatever the F his name is, is an arrogant idiot that should drop dead for inflicting this crap on us!!!

  64. 66

    Hi there. Thanks for this, very useful.

    However, the ‘hack’ I want to use (no 1) doesn’t work. Firstly it seems there aren’t enough php tags, and secondly, when containing php elements in php tags, the code fails to pull the post from the database or recognise the timestamp. I may be doing something wrong, but have you actually tested this one?

    If so, is there some setting the time format must be on to make it work or something? Real shame, cos it would be THE perfect solution I’m looking for…

  65. 67

    Thanks, I was specifically looking for the thumbnail/custom field thing. Now I just need to find the best way to have user submitted content for a wordpress blog (with image uploads).

  66. 68

    Guys, you are great. Some great collection. I found the “add a thumbnail” one extremely useful. Thank you so much and keep up the good work.

  67. 69

    Hey there, great post! I’ve been hacking through template tags for a long time trying to get my post title and description correct. I want to include a single tag and a single category within the title tag and description tag of my entry pages but still cannot figure out how to do it… Can anyone here tell me how that could be done? Would I need a custom loop? I was hoping that just putting in And would do it but it hasn’t worked. Here is what I am going for, I’ve already got my post title working, just need the cat and tag pieces.

    Post Title **category the post is in** And **tags the post has associated with it**

  68. 70

    The post-img custom field for thumbnail is great. It actually works with external links BUT it doesn’t work with images already uploaded on my website.
    It will won’t automatically display the thumbnails from the images uploaded in previous posts. So I have to edit all my previous posts which have thumbnails and add the “post-img”? Can you guys make it work with uploaded images also???

    PLEASE ANSWER THIS QUESTION because I have searched on google for hours and no one knew the answer.

  69. 71

    Thank You for this awesome how to and list! I will defiently implament some of them into my blog.

  70. 72

    great bro!

  71. 73

    Hey, in #6 – adding CSS via custom fields, the closing style tag should have a forward slash…

  72. 74

    I LOVE YOU. Thanks for an awesome post.

  73. 75

    Digg coding is still not working…

    Parse error: syntax error, unexpected ‘}’, expecting ‘,’ or ‘;’ in /home1/ohiommco/public_html/blogs/testblog/wp-content/themes/default/single.php on line 62

  74. 77

    Pedro Magalhães

    February 21, 2010 11:56 am

    Occasional this tiny function saved me a huge time!
    So thank YOU nº9! ^_^

  75. 78

    Thnx man!
    Great job, I had a lot from this blog!
    Especialy this:

    ID, ‘post-img’, true);
    if ($postimageurl) {
    <a href="” rel=”bookmark”><img src="” alt=”Post Pic” width=”200″ height=”200″ />

    <a href="” rel=”bookmark”><img src="/images/wprecipes.gif” alt=”Screenshot” width=”200″ height=”200″ />

    Searched it on and stuff but never find it. But now!
    thnx man!

  76. 79

    Thanks for the great post.

    If anyone else has been looking for a solution to using custom fields on category pages, here’s a quick tutorial:

  77. 80

    Can anyone direct me to find some article about displaying list of pages with at least 3-5 custom fields ? I’m almost for 14 days searching on internet, I have only found the article of author of this post (WP Recipes – Jean-Baptiste Jung) , but there is only one custom field:
    . I asked him for the help to add more fields but instead of answer that he has no time or will to help or that he doesn’t have the time to think or he doesnt know the answer he eliminated my question and without any explanation banned my address (@ Jean …at least You should let somebody else to answer )
    Does anybody knows any article where somebody explains how to display more fields in list of pages?
    I have changed my wp-pages into girl’s portfolios so i need list of girls with the girl’s names(page title), country,province,city,age etc.
    Thanks a lot Daniel

    • 81


      October 12, 2010 6:39 am

      Just add more custom fields to the ‘meta_key’ variable, separating them with commas

  78. 82

    thank you, very useful!

  79. 83

    I know this is an old post, but I’ve recently found it during a search. I just wanted to mention that you forgot to close your ‘else’ statement in Example 2. There should be a closing ‘curly bracket’ before your ‘endwhile’.

  80. 84

    thanks !

    your blog is really interesting.

  81. 85

    I always uses your blog when ever i want some sort of help.

  82. 86

    Benjamin Langlois

    June 1, 2010 7:55 am

    Great list as usual, however in #4 (Add Meta Descriptions To Your Posts) is there any reason why one couldn’t instead use a conditional tag for single posts to utilise the post’s excerpt instead of having to enter a custom field value for each post? This seems like the easiest solution for those of us using the excerpt feature unless there is a problem with this I am overlooking?

    PS: Have just realised this post is over a year old which might explain things.

  83. 87

    Re-Define The Tag code is not works in wp 2.9.2.
    I tried for several times and thera no changes with my page title

  84. 88
  85. 89

    Blogtek Media

    August 19, 2010 12:57 am

    Very interesting posts with lots of knowledge to get from. Thanks for the hacks ;)

  86. 90

    Thanks alot for this post, I’ve been looking everywhere for something on custom fields and this sure did do the trick. Cheers!

  87. 91

    I use custom fields for meta description tags for posts. Thanks for the hacks

  88. 92

    Thank you so much for this explanation! I’ve been trying to change the display of one archive to be in ascending date order and in the sidebar have the index be in ascending alphabetical order.

  89. 93

    Michael Shearer

    December 22, 2010 12:19 pm

    Thanks for the “Display Thumbnails Next to Post”…was looking for code to show if there was an entry otherwise display a default image.

  90. 94

    Another way of achieving this is given at . Read How to Create WordPress Thumbnail Based Post Archives

  91. 95

    for seo i recomend you use All in One SEO or the new plugin created by YOAST, WordPress SEO, which has a cool preview feature to view how your post will be displayed on search engines! thanks for sharing !

  92. 96

    Great post, but I need to know how to make the custom field have the same value, so I don’t have to insert the value over and over again.

  93. 97

    Great post. I’ve been using WordPress for a while, now i want to be a little more advanced and this is perfect. Thanks!

  94. 98

    Can anyone help me with how to replace a custom field value with an image?

    What i want to achieve is replacing a custom field rating between 1 – 5 with the relevant star image, so that for example if the value is 4 it displays the 4star image in the place.

    Gotten so far as to making the value display, but all the attempts to replace with an image has left me with just a placeholder instead of the image itself, although the source code looks correct.

    Need help!

  95. 99

    Rafael Antunes

    March 15, 2011 3:17 pm

    Very Instructive, and accurate code.
    thank you.

  96. 100

    Very great examples

    Thank you dear

    I used thumbnails example in my blog برامج مجانية

    My Regards

  97. 101

    For category custom fields there is this plug in :

  98. 102

    How do I make ALL fields display publicly in the comments – including email, website and custom fields?

  99. 103

    #5 Does anyone know how to do this with the rollover image, not just the post title? The rollover is here:

  100. 104

    Anyone know how to make custom fields required before publishing the post?


↑ Back to top