• travinum1

    (@travinum1)


    So I created a custom field.. lets say its name is ‘customfield’.
    How would I write a conditional statement, stating that if the value for ‘customfield’ is ‘yes’, to echo out some HTML? In addition to that, if the value for said custom field is blank then nothing should be echoed out.

Viewing 1 replies (of 1 total)
  • vtxyzzy

    (@vtxyzzy)

    Assuming you are in the Loop, this should work (untested):

    $value = get_post_meta(get_the_ID(), 'customfield', true);
    if ($value == 'yes') {
       echo "some HTML";
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional statements for custom fields..’ is closed to new replies.