I insert author box below my post and use get_the_author to return author name but it doesn't working. It also doesn't working with Search post by author. Hope everyone give me solution, thank in advance.
Echo it out...
<?php echo get_the_author(); ?>
echoing worked for the OP, the issue could be related to setting up the post manually, as was in my case. Here is the code:
$post = get_post(); setup_postdata($post); // setting up the post manually // Then you can fetch/echo the author name var $authorName = get_the_author(); var $content = get_the_content(); // This works too
As a general rule, any WP function beginning with
get_ will return the result rather than echoing it. There's usually a corresponding function - in this case it's
the_author() - which will echo it.