Posted By

raz on 01/05/11


Tagged

wordpress field custom customfield chek


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

baires
qubestream


If custom field exists


 / Published in: PHP
 

URL: www.h3ostudio.com

This snippet check for custom field value (customfieldname), if there is nothing it will display default value (alternative text). This is my first WordPress Snippet :)

  1. <?php $somevar = get_post_meta($post->ID, 'customfieldname', true);
  2.  
  3. if($somevar) {
  4.  
  5. echo $somevar;
  6. } else {
  7. echo 'alternative text';
  8. }?>

Report this snippet  

You need to login to post a comment.