WordPress.org

Forums

get post custom values (6 posts)

  1. nickolasalvarado
    Member
    Posted 7 years ago #

    Whenever I use get_post_custom_values, it does not return anything even though I have set up a custom field and have verified it within the wordpress database. So here's my code:

    $value = get_post_custom_values('somevalue');
    foreach ($value as $key => $value) { echo $key."-".$value."
    "; }

    I was doing this as a quick test to see if the values would even show up and they were not. So I did a quick test:

    if ($value) { echo "set"; } else { echo "unset"; }

    I added that into the template to see if the variable was even being set and it was not. I have tried multiple things and nothing works. I need to be able to do this for the website to work correctly. Has anyone else had this problem?

  2. nickolasalvarado
    Member
    Posted 7 years ago #

    bump

  3. nickolasalvarado
    Member
    Posted 7 years ago #

    bump

  4. iridiax
    Member
    Posted 7 years ago #

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

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

  5. nickolasalvarado
    Member
    Posted 7 years ago #

    the problem is that the variable that holds the array never actually gets set into an array. the function is not pulling the values from the database table.

  6. iridiax
    Member
    Posted 7 years ago #

    Your code is not the same as the one I posted. Try using the code from the codex.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.