Custom fields are definitely very useful and are used on many WordPress-powered blogs. In this recipe, I’m going to show you how to easily get custom fields values outside the loop.
To display a custom field value outside the loop, simply use the following code. Don’t forget to replace customField on line 4 by the name of the custom field you want to display.
<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'customField', true); ?>