Certain post data not showing


/ Published in: PHP
Save to your folder(s)

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)


Copy this code and paste it in your HTML
  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. '

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.