WordPress.org

Ready to get started?Download WordPress

Forums

Help with custom fields (12 posts)

  1. Jack
    Member
    Posted 10 years ago #

    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?

  2. OperaManiac
    Member
    Posted 10 years ago #

    http://blog.sushubh.com/archives/2004/03/19/apple-store-typo-g5/
    i used meta post for movie i saw today and stuff...
    but yeah, adding icons should be possible...
    http://wiki.wordpress.org/index.php/PostMeta

  3. Jack
    Member
    Posted 10 years ago #

    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?

  4. Jack
    Member
    Posted 10 years ago #

    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.

  5. OperaManiac
    Member
    Posted 10 years ago #

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

  6. nolageek
    Member
    Posted 10 years ago #

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

  7. georgianlady
    Member
    Posted 10 years ago #

    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'>

  8. <span class='post-meta-key'>Reading:</span> Pendragon Cycle, Mansfield Park

  9. 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

  • nolageek
    Member
    Posted 10 years ago #

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

  • Anonymous
    Unregistered
    Posted 10 years ago #

    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.

  • Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

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

  • p5hng
    Member
    Posted 10 years ago #

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

  • timothyb
    Member
    Posted 9 years ago #

    Yay! Thanks for the simplified explanation. I was able to add a "found via" field on my posts http://www.greendigit.com

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.