Posted By

maximaker on 07/13/10


Tagged

wordpress fields theme custom


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

maximaker
lanceosborne


get custom fields value in wordpress theme


 / Published in: PHP
 

URL: http://codesnippets.info/wordpress/get-custom-fields-value/

get custom fields value in wordpress theme

  1. To be used only inside WordPress’s Loop
  2.  
  3. <?php echo get_post_meta($post->ID, 'custom_field_name', true); ?>
  4.  
  5. It displays the value of the custom field. Replace “custom_field_name” with the chosen name of your custom field.
  6.  
  7. To display the value outside the loop use
  8.  
  9. <?php
  10. global $wp_query;
  11. $postid = $wp_query->post->ID;
  12. echo get_post_meta($postid, 'custom_field_name', true);
  13. ?>

Report this snippet  

You need to login to post a comment.