Forums

getting 2 custom values to display in a post? (9 posts)

  1. vsp
    Member
    Posted 5 years ago #

    right now i have two custom values, one for Author information and one for a Surtitle. The author part is working fine, and is showing up on the page with this code:

    <?php
    $custom = get_post_custom_values('Author');
    if (count($custom) != 0)
    {
    // do your thing
    echo $custom[0];
    // maybe do more things
    } ?>

    but I can't get it to display another custom value, even though I think I'm changing all the right variables. could anyone give me some help in displaying 2 different custom values on one page?

  2. maerk
    Member
    Posted 5 years ago #

    Are you trying to echo more things in the $custom array?

    If so:

    echo $custom[0];
    echo $custom[1];
    // etc

    Also, are you sure it's a numbered array, and not an associative array? I.e.:

    echo $custom['Author'];
    echo $custom['Other_detail'];
    // etc

  3. vsp
    Member
    Posted 5 years ago #

    i'm trying to echo the value of a custom field called "surtitle"

  4. maerk
    Member
    Posted 5 years ago #

    Try either $custom[1] or $custom['surtitle'].

  5. vsp
    Member
    Posted 5 years ago #

    i tried those, and neither one works

  6. maerk
    Member
    Posted 5 years ago #

    Also have you checked out this:

    http://codex.wordpress.org/Using_Custom_Fields

    Try:

    echo get_post_custom_values('Author');
    echo get_post_custom_values('surtitle');

  7. vsp
    Member
    Posted 5 years ago #

    that's not working either.

  8. vsp
    Member
    Posted 5 years ago #

    now it's displaying something at least, but it's just displaying the word "Array"

  9. WillHines
    Member
    Posted 5 years ago #

    Maybe underneath

    // maybe do more things

    try

    print_r($custom)

    to see what's getting put in there.

Topic Closed

This topic has been closed to new replies.

About this Topic