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