Posted By

Farhan on 12/03/10


wordpress field custom

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Check if Custom Field Exist

 / Published in: PHP

  1. <?php $thereisimage = get_post_meta($post->ID, image, true);
  2. if($thereisimage){ ?>
  3. <a href="<?php the_permalink() ?>"><img src="<?php echo get_post_meta($post->ID, image, true); ?>" alt="Image" /></a>
  4. <?php }else{ ?>
  5. <a href="<?php the_permalink() ?>"><img src="images/default.png" alt="Default Image" /></a>
  6. <?php } ?>

Report this snippet  

You need to login to post a comment.