WordPress: How to get custom fields outside the loop

» Posted by on Jan 20, 2012 in Blog, Web Development, Wordpress | 0 comments

Displaying custom field data from a WordPress page, post, or custom post type is very easy. Simply access WordPress’ global query and grab the custom field you need!

global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'customFieldSlug', true);

Related posts:

  1. Sort Custom Post Types in WordPress Admin
  2. Facebook: Post & Comment as Fan Page Name

Submit a Comment