• Resolved wrimomatt

    (@wrimomatt)


    I’m using a select list meta box and want to be able to check the value and if a certain value is present do one thing and if not, do another. I’ve done this with a simple text box a million times, but can’t get it to work with select. If it was just a text field I’d do this:

    <?php if(get_post_meta($post->ID,'select-name', true)): ?>
    DO THIS THING
    <?php else: ?>
    DO THIS THING INSTEAD
    <?php endif; ?>

    I think I have to check on the key first, and then the value, but haven’t had much luck with the things I’ve tried.
    Any help appreciated + Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter wrimomatt

    (@wrimomatt)

    okie dokie. So, if anyone else finds this and needs to do the same thing inside a loop, this is what worked. If you think the code can be improved upon, chime in.

    <?php if('select-value#1' == get_post_meta($post->ID,'select-name', true)): ?>
    DO THIS THING
    <?php else: ?>
    DO THIS THING INSTEAD
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘if meta value selected’ is closed to new replies.