Return to Snippet

Revision: 28728
at July 13, 2010 08:50 by maximaker


Initial Code
To be used only inside WordPress’s Loop

<?php echo get_post_meta($post->ID, 'custom_field_name', true); ?>

It displays the value of the custom field. Replace “custom_field_name” with the chosen name of your custom field.

To display the value outside the loop use

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

Initial URL
http://codesnippets.info/wordpress/get-custom-fields-value/

Initial Description
get custom fields value in wordpress theme

Initial Title
get custom fields value in wordpress theme

Initial Tags
wordpress, theme

Initial Language
PHP