The Never-Ending Bloga

Using Custom Fields « WordPress Codex

Using Custom Fields « WordPress Codex

I haven't been able to figure this feature out, but I'd like to get it working if possible. This tutorial makes it sound so easy, like the jitterbug, but it plum eluded me the last time I tinkered with it.

Supposedly, you can get it to do all kinds of things, but the simplest are adding moods and "Currently Reading" and such.

Here is an example of what this information might look like on your post:

Currently Reading: Calvin and Hobbes

Today's Mood: Jolly and Happy

Usage

Based upon our example above, let's put this into action. We'll add two custom fields, one called "Currently Reading" and the other "Today's Mood". The following instructions will demonstrate how to add this information to a post using Custom Fields.

  1. From the Write Post panel, choose Advanced Editing. If you are using the Simple Editing screen, look for a button with Advanced Editing » next to the Publish button. Click the button to go to the advanced editing screen.
  2. After you have written your post, scroll down to the bottom of the Advanced Editing screen and look for an area titled Custom Fields.
  3. To create a new Custom Field called "Currently Reading", enter the text "Currently Reading" (without the quotes) in the text entry field titled Key.
  4. The newly created Key should now be assigned a Value, which in our case is the name of the book currently being read, "Calvin and Hobbes". Type "Calvin and Hobbes" in the Value field, again without the quotes.
  5. Click Add Custom Field button to save this custom information for that post.

To add your "Today's Mood", repeat the process and add "Today's Mood" to the key and a description of your mood in the value text boxes and click SAVE to save this information with the post.

 So. I've added a "Mood" and a "Currently Reading" field but it's not visible… until maybe I publish? Let's see here…

Ah. I have to add a tag or two to a template: 

Displaying Custom Fields

With a Custom Field added to the post, it's time to display your books and mood to the world. To display the Custom Fields for each post, use the the_meta() template tag. The tag must be put within The Loop in order to work. Many people add the_meta() template tag to the end of their post or in their Post Meta Data Section. Here is a basic example of using the tag…

I omitted a lot of tag chaff, but the gist is, you put a tag in the template that governs how the blog – WordPress is a bit anarchic, and the name of the file varies with the theme that you are using – sometimes "index.php" just shows a link to the theme's master index, and sometimes it's really the main index file itself. In this theme, it's in the theme master index, and I sort of got it working but I think I need to move it into the next div.

UPDATE: Sort of got it working, it's not behaving exactly as I'd hoped, and now I'm going to bed, to blog another day about why tinkering with this crap keeps me from thinking about work…

Leave a Reply

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