Support » Fixing WordPress » Help with custom fields

  • I read the wiki about the use of custom fields, but it didn’t enter my consciousness I’m afraid. Could someone give me a live example of the use of these fields? And could they be used to attach images to words?
    In my site I use 4 different icons to describe the kind of post it is. In MT I used categories to do this. I could do this now as well (although I didn’t succeed yet), but perhaps a custom field is much easier?

Viewing 11 replies - 1 through 11 (of 11 total)
    i used meta post for movie i saw today and stuff…
    but yeah, adding icons should be possible…

    I read that part on the wiki-site, but I don’t understand it.
    * Is the key “The movie I last saw” and the value “Finding Nemo”?
    * And what is the php-code you used in your index.php?

    I tried it myself and it works, but partly. I mean, when I insert <img src=”plaatjes/vergroot.gif”> in the keyfield or the equivalent (<img src="plaatjes⁄vergroot.gif">), and leave the value blank or just a whitespace, nothing happens. When I fill in ‘:’ or something like that it works nicely. But when editing another post, or re-editing that last post, I won’t be able to choose that code again, other than pasting it manually in the keyfield.

    weird WP is supposed to save the values of the key…

    How do you use this in your templates? I dont understand what the wiki says about that.

    OK Here’s How I Did It just now:
    I made a post and created a “Reading” key in the custom fields area below the writing area of a post. In the “value” I put a book I’m reading.
    I then saved the post, and then chose the drop down “select” to choose “Reading” from the “add a new custom field” and input a second book I’m reading into that value field.
    So I had two custom keys there, both called “reading” with different values, a different book each.
    On the index.php template I put this:

    <?php the_meta() ; ?>

    in the same div as holds the post title and categories the post is filed under, etc. I have it placed underneath all that stuff so that it shows up last.
    I published the post and this is the output I got:
    “Reading: Pendragon Cycle, Mansfield Park”
    This is what it looks like on the Source of the web page:

    <ul class='post-meta'>

  • <span class='post-meta-key'>Reading:</span> Pendragon Cycle, Mansfield Park
  • Posts that have no custom field entries do not show any of the above last code on the source … so only meta data shows up this way in posts that it’s entered as this thread is stating.
    I puzzled over this thread and custom fields a few times the last week, and then decided to tackle it today. It took me 5-minutes to finally read, and implement, so I wanted to write this so that anyone else can figure out how to at least put per-post-meta-data in via custom fields.
    It was simple. I look forward to seeing further implementation from plugins and new tags!
    See it on my post testing Meta

Awesome. That’s definately a little clearer than the wiki. Thanks for the examples.

If a dev reads this, It would be nice to have the_meta called in the default so that new users didn’t end up having to puzzle over this so much.

Moderator Scott Reilly


WordPress & Plugin Developer

Try the Get Custom Field Values plugin. (Support forum thread here.)

Thats exactly what I was looking for! Thank you very much. 🙂



Yay! Thanks for the simplified explanation. I was able to add a “found via” field on my posts

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Help with custom fields’ is closed to new replies.