Support » Plugin: Advanced Custom Fields » [Plugin: Advanced Custom Fields] If condition

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php if( get_post_meta($post->ID, "mycustomfieldname", true) ): ?>
    <?php echo get_post_meta($post->ID, "mycustomfieldname", $single = true);?>
    <?php else: ?>
    text 2 (add your default message here).
    <?php endif; ?>

    If you have added something to the custom field (mycustomfieldname), then it will be displayed by the second line code.
    If you have it blank, then it’ll show any default text you add it as default.



    Thank you so much, it works perfect 😀
    Thanks again

    Plugin Author elliotcondon


    Have a look at the get_field function. It’s a lot cleaner than what you are using.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Advanced Custom Fields] If condition’ is closed to new replies.