WordPress.org

Ready to get started?Download WordPress

Forums

Display Selected Custom Name and Value (4 posts)

  1. fruitshakes
    Member
    Posted 2 years ago #

    Hi,

    I would like to know how to display selected custom name and value in a post? I've been doing:
    <?php the_meta(); ?>
    but it shows all custom values. I want to show only selected values.

    Thanks!

  2. JarretC
    Member
    Posted 2 years ago #

    Is get_post_meta (http://codex.wordpress.org/Function_Reference/get_post_meta) what you're looking for?

  3. fruitshakes
    Member
    Posted 2 years ago #

    Yup. But it shows only the values. Is there a way to show both the name and value?

  4. jnhghy
    Member
    Posted 2 years ago #

    Hi,
    When you echo get_post_meta, you use the meta_key as parameter, just echo the meta_key along with get_post_meta.
    $meta_key = "your_meta_key";
    $meta_value = get_post_meta($post_id,$meta_key,"true");
    echo $meta_key. " => ".$meta_value;
    This is one way.
    Regards

Topic Closed

This topic has been closed to new replies.

About this Topic