Posted By

Rembrand on 08/30/10


Tagged

wordpress


Versions (?)

Certain post data not showing


 / Published in: PHP
 

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

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)

  1. src: http://wordpress.org/support/topic/the_author-not-displaying-anything-ideas
  2.  
  3. When not using the loop, you need to manually prepare the data with setup_postdata($post), as such:
  4.  
  5. '
  6. $query = get_posts('showposts=5');
  7. foreach($query as $post) {
  8. setup_postdata($post); //loads all data, including meta for access
  9.  
  10. //resume adding template tags as normal
  11. }
  12. '

Report this snippet  

You need to login to post a comment.