1

For some reason my by author disappeared and I cant turn it back on. I know where I want to put it on single.php at the end of the post, but I can't figure out what code I have to put in for it to display.

1

Inside The Loop you can use the Template Tag the_author() to display or get_the_author() to return the same. For an introduction to outside the loop usage take a look at the Q&A's at the thread How to get Author ID outside the loop on here.

1

The property on the object for author is post_author. You can access it like this in the loop where $post is your WP_Post object.

$author = $post->post_author;

If you want to display it:

echo $post->post_author;
  • 1
    this will display nothing ;) – Mark Kaplun Sep 26 '14 at 13:05
  • There, smarty pants :P – Christopher Lamm Sep 26 '14 at 13:40
  • :) allow me to be pedantic a little bit longer, what you output is the user ID of the author, which you rarely want to display. probably need to get the user data using the user id and then echo its display_name :) – Mark Kaplun Sep 26 '14 at 15:08
  • You're absolutely right. Derp. ialocin, answer is easier anyway. – Christopher Lamm Sep 26 '14 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.