Using WordPress Custom Fields

Using WordPress Custom Fields is actually much easier than one would think. I went to use it a while back for a project and didn’t really have time to work with it so I passed it by. But recently I needed it and was surprised at how easy it is to use it! With one little line of code in your template you can use Custom Fields in WordPress.

When you’re in WordPress and you want to add a Custom Field to a blog entry all you need to do is scroll down to where it shows the Custom Field options. We’ll use the standard Mood: Happy example as used on the WordPress website. In the ‘Name’ box we’ll type Mood and in the Key or Value option we type Happy. After you save your post and try and view the live version you will see that it has had no effect on your post! Hmm… referencing the little line of code that we mentioned above, that’s what we need!

And that line of code is as follows:

<?php the_meta(); ?>

So plug that in your template wherever you’d like to see the data loaded! Upload your revised template and refresh your blog and you should see the data! Now you can get really involved and do some really cool stuff with CSS to really put the Custom Field to use! In this example we’re really only using the Custom Field at it’s simplest. Take a look at the WordPress Using Custom Fields page to really get your hands dirty!

PS: Also note that you can use Custom Fields for Pages as well!

Stay In The Loop

Social Gathering

Join our newsletter to get notified about the happenings here at J Taylor Design.