• Resolved lucrothe

    (@lucrothe)


    Hello,

    First time poster, I hope I have this the right location… so here goes:

    I have a custom drop down field called ‘cp_cat’ with options of ‘yes’ and ‘no’.

    The value is set to yes but when I view the post the text is showing no. Here is the code:

    <?php if (get_post_meta($post->ID, 'cp_cat', true ))
        if($value == 'yes') {
              echo 'yes';
           }
        else {
              echo 'no';
           }
    
        ?>

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    //Note: also will display no if custom field DOES NOT exist
    $value = get_post_meta($post->ID, 'cp_cat', true);
    if ($value == 'yes') {
      echo $value;
    } else {
      echo 'no';
    }
    ?>
    Thread Starter lucrothe

    (@lucrothe)

    Hi MichaelH,

    Thank you for taking the time to respond. The code worked great!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Accessing data from a custom drop down field’ is closed to new replies.