Code

Get custom field outside the WordPress loop

Friday, October 29th, 2010

Do you want to get a custom field outside the WordPress loop (e.g. in your sidebar) and you have no idea how? The following code snippet will help you do it.
* Replace the ‘customField’ in the 4th line with the name of your custom field.

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'customField', true);
?>

Source: www.wprecipes.com/wordpress-how-to-get-custom-fields-outside-the-loop

read more...

Popular Posts in WordPress | posted on: Thursday, March 4th, 2010


Creating a Simple Shortcode | posted on: Friday, February 12th, 2010


WordPress “Send to Twitter” Button Without Using a Plugin | posted on: Friday, February 12th, 2010


WordPress Alternating Comments Styles | posted on: Friday, February 5th, 2010


WordPress Related Posts without using a Plugin | posted on: Wednesday, February 3rd, 2010


Include jQuery in your WordPress Theme | posted on: Tuesday, February 2nd, 2010


Display Recently Updated Posts/Pages | posted on: Monday, January 4th, 2010


Display Recent Posts | posted on: Monday, January 4th, 2010


What Are Shortcodes? | posted on: Tuesday, December 29th, 2009