Saturday, July 23, 2011

Display Custom Fields Outside Loop in WordPress

How to Display Custom Fields Outside The Loop in WordPress

When you need to display post-specific content for example a data for a specific post. Usually post specific contents are added via a custom field which can only be displayed inside a post loop.Here we will show you how you can display custom fields outside the loop.

Please check the following code:


global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Your-Custom-Field-data', true);
wp_reset_query();


You will need to make sure that you change the part where it says “Your-Custom-Field-data”.

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off