Viewing 1 replies (of 1 total)
  • You could use the default wordpress function get_post_meta(). See an example from the WordPress official documentation:

    <?php if ( get_post_meta( get_the_ID(), 'thumb', true ) ) : ?>
        <a href="<?php the_permalink() ?>" rel="bookmark">
            <img class="thumb" src="<?php echo get_post_meta( get_the_ID(), 'thumb', true ); ?>" alt="<?php the_title(); ?>" />
        </a>
    <?php endif; ?>
Viewing 1 replies (of 1 total)

The topic ‘PHP: how to Hide code if field is empty?’ is closed to new replies.