Conditional Statement if Custom Field Exists Wordpress


/ Published in: PHP
Save to your folder(s)

Only show content if Custom Field exists


Copy this code and paste it in your HTML
  1. <?php if (strlen(get_post_meta($post->ID, "direct dial", true)) > 0) : ?>
  2. <p class="direct_dial"><strong>DD</strong> <?php echo get_post_meta($post->ID, "direct dial", true);?></p>
  3. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.