get author in blog posts?

What do I need to do in order to have the author name in the blog posts on my wordpress blog?

currently when I view a post it doesn’t have the author that wrote the post.

Related posts

Leave a Reply

2 comments

  1. This will be somewhat dependent on where your single post view is stored, but you’d be looking to add something to the effect of:

    <?php
    
    echo __('Written by', 'text_domain') .' <a href="'. get_author_posts_url(get_the_author_meta('ID')) .'" rel="author" class="fn">'. get_the_author() .'</a>';
    
  2. The code needs to go in single.php, which you’ll most likely find in your theme folder. If you are using a child theme, you might not see it; in which case, copy the file from the parent theme to your child theme folder.
    The WordPress function you need is the_author, so to get the author’s name, add something like this inside the loop:

     <p>This post was written by <?php the_author(); ?></p>