Posted By

wahnbriefe on 08/01/11


Tagged

wordpress fields custom


Versions (?)

If custom field has content


 / Published in: PHP
 

Good for showing labels/descriptions that accompany custom fields when they are set, and avoiding lots of empty labels. Eg: if there is no content set in the 'project-agency' field, don't show the label 'Agency:', but if there is, show it with the content.

  1. <?php
  2. $themeta = get_post_meta($post->ID, 'project-agency', TRUE);
  3. if(!empty($themeta)):
  4. ?>
  5.  
  6. <strong>Agency:</strong> <?php echo get_post_meta($post->ID, 'project-agency', true); ?>
  7.  
  8. <?
  9. endif;
  10. ?>

Report this snippet  

You need to login to post a comment.