WordPress.org

Ready to get started?Download WordPress

Forums

display all the custom fields in the current post (3 posts)

  1. nadine00
    Member
    Posted 3 years ago #

    Hi,

    I'm looking for a simple way to print or echo all the custom fields associated with a current post, without pulling them in a single like manner. So basically just a big dump in a list of all the custom fileds in a post.

    I've been tooling around with this:

    http://codex.wordpress.org/Function_Reference/get_post_custom

    But I can't get it to actually work. I've looked at snippits and functions online but they seem very complicated.

    Does anyone have a suggestion on how to do this?

    Thank You

    Nadine

  2. nadine00
    Member
    Posted 3 years ago #

    Well <?php the_meta(); ?> worked, but now I have to basically find a way to do this:

    <li><a href="$meta_value">$meta_key</a></li>

    Which I think involves some kind of array parsing. But I am currently unsure on how to achieve this.

    Thanks.

    Nadine

  3. nadine00
    Member
    Posted 3 years ago #

    Soooo....I can get the keys using http://codex.wordpress.org/Function_Reference/get_post_custom_keys ...but the values want a specific key in the options.

    I still don't know why the original custom snippit does not work: `<?php

    $custom_fields = get_post_custom($post->ID);
    $my_custom_field = $custom_fields['my_custom_field'];
    foreach ( $my_custom_field as $key => $value )
    echo $key . " => " . $value . "<br />";

    ?>`

    Stumped.

    Anyone? Or another way to pull values?

    Thanks

    Nadine

Topic Closed

This topic has been closed to new replies.

About this Topic