View Single Post
Old 02-09-2012, 11:38 AM  
madtwin
Confirmed User
 
Industry Role:
Join Date: Aug 2009
Posts: 274
Ok guys, thank a lot for the info.

I found the solution, maybe someone will find it useful too:

Displaying Custom Fields Outside The Loop

There are times, when you need to display custom fields outside the loop, e.g., in the footer of the blog post. Displaying custom fields outside the loop will allow you, for example, to have a different footer for each blog post. To achieve, this two things need to be done.

1. Edit the blog post template (e.g., single.php) to make post ID available outside the loop. Find the line

Code:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
and add the following code just below it:

Code:
<?php $GLOBALS['current_id'] = $post->ID; ?>
2. Use this code to display your custom field outside the loop, e.g., in the footer.php

Code:
<?php echo get_post_meta($GLOBALS['current_id'], "custom-field-name", true); ?>
That?s it! Now, when editing a blog post, add a custom field with ?custom-field-name? and it will display wherever you put that second bit of code.

source (through google cache)
madtwin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote