Using WordPress custom fields

I learned how to use WP’s custom fields tool today. My client runs a magazine, and today I had to enter a number of articles from past issues into the blog.

I didn’t want the ‘Written by ____’ to show when the article was actually written by someone else who isn’t an editor of the blog. So I created a custom field called ‘Author’ and entered each article writer’s name on each post.

Then I went into my template (index.php, archives.php, single.php and any other file where the loop is shown) and added this tag where I wanted the field to show up:

This generates an unordered list, not really what I wanted.

After a little poking around I found this custom fields plugin. With this tool I can replace the meta tag with a more focused one:

This was much better – I just put this snippet into the same theme files, then styled it with CSS.

One final thing – I’d added ‘Written by’ just before the author’s name, so I changed the ‘Written by’ that occurs with the date right under the post title with ‘Blogged by.’ I’m not sure what the client will think about that, but it does a good job of distinguishing the blog poster from the article writer.

Leave a Reply

Your email address will not be published. Required fields are marked *