Display Custom Fields Outside The Loop in WordPress


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



Copy this code and paste it in your HTML
  1. <?php
  2. global $wp_query;
  3. $postid = $wp_query->post->ID;
  4. echo get_post_meta($postid, 'Your-Custom-Field', true);
  5. wp_reset_query();
  6. ?>

URL: http://www.wpbeginner.com/wp-themes/how-to-display-custom-fields-outside-the-loop-in-wordpress/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+wpbeginner+(Wordpress+for+Beginners)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.