• I’m trying to get a conditional statement running on a custom field I’ve collected.

    If post_meta “testfield” = 1, do this
    else if post_meta “testfield” = 2, do this.

    This is what I originally had, close but no cigar.

    <?php if ( get_post_meta($post->ID, "testfield", true) ) { ?>
    <img src="image.jpg"/>
    <?php } ?>

    Any help appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php $customF = get_post_meta($post->ID, 'testfield', true);
       if($customF == '1') { ?>
         <img src="image.jpg"/>
    <?php } elseif($customF == '2') { ?>
         <!-- what do you want to do here? -->
    <?php } ?>
    Thread Starter r2o4l7l

    (@r2o4l7l)

    That worked brilliantly! Thanks man!

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

The topic ‘If post_meta = 1 do this, else do this’ is closed to new replies.