Use Custom Fields in Wordpress


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



Copy this code and paste it in your HTML
  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 } ?>

URL: http://forthelose.org/how-to-use-custom-fields-in-wordpress

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.