Advertisement
sayful

WP Custom Fields

Jan 18th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. /****************************************************************
  2. * To use custom fields put the following code where you want use
  3. * Replace 'key' by your custom fields name
  4. ****************************************************************/
  5. <?php echo get_post_meta($post->ID, 'key', true); ?>
  6.  
  7. /****************************************************************
  8. * The following code will show custom fields when you set custom field
  9. * Other wise it won't show the custom fields
  10. * Replace 'key' by your custom fields name
  11. ****************************************************************/
  12. <?php if ( get_post_meta( get_the_ID(), 'key', true ) ) : ?>
  13.     <a href="<?php the_permalink() ?>" rel="bookmark">
  14.             <img class="thumb" src="<?php echo get_post_meta( get_the_ID(), 'key', true ); ?>" alt="<?php the_title(); ?>" />
  15.     </a>
  16. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement