How to create an author page in WordPress

How to Create a Custom Author Page in WordPress

Do you want to know How to Create a Custom Author Page in WordPress? You are in the right place. I will teach you about it in this article. 

Blogs, News, magazines, and other types of websites need an author identification page so that visitors will know about the author. It is important for branding yourself. You can be kept communicating with visitors.  

Create an Author Page in WordPress:

If you don’t maintain lots of authors. So, you can create an author page manually. Most of my articles are for WordPress Theme developers who know basic PHP. But others still can do it without knowing anything. I recommended to everyone try to avoid using plugins. 

Before creating an author template, You need to know about template hierarchy. The Template Hierarchy specifies that WordPress uses the first Template file it finds in your current Theme’s directory from the following list:

  1. Author-{nicename}.php
  2. Author-{id}.php
  3. Author.php
  4. Archive.php
  5. Index.php

We will create an author.php template for the author page

Then create a file in the theme directory named author.php. If you are using a child theme then create that file in the child theme. 

Here you want to create an author profile page. You can create anything between get_header() and get_sidebar(). For a standard example, I will show you just those codes which we need. You need to put get_header(), get_sidebar() and get_footer() where you need. 

Copy this code paste between get_header() and get_sidebar() on author.php:

<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
 ?>
<h2>About: <?php echo $curauth->nickname; ?></h2>

<div class="author-info">
    <div class="autor-img"> <?php echo get_avatar( $curauth->user_email , '90 '); ?></div>
    <p><strong>Full Name:</strong> <?php echo esc_attr($curauth->first_name) ?> <?php echo esc_attr($curauth->last_name) ?></p>
    <p><strong>Website:</strong> <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></p>
    <?php if($curauth->user_description != ''): ?>
    <p><strong>Bio:</strong> <?php echo esc_attr($curauth->user_description); ?></p>
    <?php endif; ?>
</div>

<h2>Posts by <?php echo $curauth->nickname; ?>:</h2>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
        <?php the_title(); ?></a>,
        <?php the_time('d M Y'); ?> in <?php the_category('&');?>
    </li>

<?php endwhile; else: ?>
    <p><?php _e('No posts by this author.'); ?></p>
<?php endif; ?>

Go to the author page you will see the newly added author profile. ( To get the author page link: Go, Users,>> All Users >> Hover on the list and click view) 

Conclusion

The author page is a common issue for a website. Most websites needed it. You can display your work and your information with that. 

I hope you liked this article “How to Create a Custom Author Page in WordPress”. If you have any problem or request make a comment. We are ready to help you.

See More:

How to Add reCAPTCHA to the WordPress Comment Form

Leave a Reply

Your email address will not be published. Required fields are marked *