WordPress.org

Ready to get started?Download WordPress

Forums

<?php get_post_custom_values($key);?> Not Quite Working (5 posts)

  1. digiman999
    Member
    Posted 4 years ago #

    Hello,

    I've been trying to add a custom set of Custom Fields to display under my post contents, by editing theme/index.php, adding

    <?php get_post_custom_values($Feedback);?>
    just after
    <?php the_content(''); ?>

    but nothing displays, and there's no PHP errors displayed in the browser. Have cleared the browsers cache, and <?php get_meta ?> works fine.

    Any thoughts?
    Regards

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    what is the value of $Feedback - or is 'Feedback' supposed to be the key name?

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

    besides, the function returns an array, but does not actually output anything. (see the example in the above link)

  3. digiman999
    Member
    Posted 4 years ago #

    The custom field is labelled Feedback under admin.

    I just tried several routes, all giving Invalid Argument errors, such as

    <?php
      $mykey_values = get_post_custom_values('Feedback');
      foreach ( $mykey_values as $key => $value ) {
        echo "$key  => $value ('Feedback')<br />";
      }
    ?>

    I also tried it with <?php get_post_custom_values($Feedback); ?> beforehand. I just don't understand enough about PHP to logically figure it out. What's the base code to put in, and have the Key's been entered correctly in my example above?

    Regards

  4. digiman999
    Member
    Posted 4 years ago #

    My complete code so far has been this below, but no joy. Does this look right to you all?:

    <?php get_post_custom_values($Feedback);
    $mykey_values = get_post_custom_values('Feedback');
    foreach ( $mykey_values as $key => $value ) {
    echo "$key => $value ('Feedback')
    ";
    }
    ?>

  5. luxonski
    Member
    Posted 3 years ago #

    I think you are missing argument in get_post_custom_values().

    get_post_custom_values( 'your_key', $post->ID ).

    Hope it helps

Topic Closed

This topic has been closed to new replies.

About this Topic