Return to Snippet

Revision: 31092
at August 30, 2010 02:21 by Rembrand


Initial Code
src: http://wordpress.org/support/topic/the_author-not-displaying-anything-ideas
 
When not using the loop, you need to manually prepare the data with setup_postdata($post), as such:

'
$query = get_posts('showposts=5');
foreach($query as $post) {
setup_postdata($post); //loads all data, including meta for access

//resume adding template tags as normal
}
'

Initial URL
http://wordpress.org/support/topic/the_author-not-displaying-anything-ideas

Initial Description
For example, when you can't get the post author to shop up using the_author(); it usually means your working outside the loop while that function is meant to work inside the loop.
This is a way around it. (got it from the forums)

Initial Title
Certain post data not showing

Initial Tags
wordpress

Initial Language
PHP