Custom author profile page in WordPress
In this article, we are going to discuss about custom author profile page in WordPress without Plugin. But how is it possible to display author profile on post detail page or single post page. Author keeps good impact on reader with their good article and profile shown below posted article and it is also a way to get more traffic on site. Generally free theme not comes with author.php page but for custom author page you can create author.php page in your current theme folder .In this tutorial I will show how to add author.php page for author profile display on single post page.
Create author.php page in theme root folder and put this code snippet
<?php get_header(); ?> <section id="content" role="main"> <header class="header"> <?php the_post(); ?> <h1 class="entry-title author"><?php _e( 'Author Archives', 'your theme name' ); ?>: <?php the_author_link(); ?></h1> <?php if ( '' != get_the_author_meta( 'user_description' ) ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . get_the_author_meta( 'user_description' ) . '</div>' ); ?> <?php rewind_posts(); ?> </header> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'entry' ); ?> <?php endwhile; ?> <?php get_template_part( 'nav', 'below' ); ?> </section> <?php get_sidebar(); ?> <?php get_footer(); ?>
After creating an author.php file in theme directory, we can call display author details filled by admin
On single.php(Which is basically Post detail Page). To display author profile if users have filled out description for authorprofile, we have to put snippet on single.php file which is shown below.
<?php // If a user has filled out the description of author profile, show a profile single post page if ( get_the_author_meta( 'description' ) ) : ?><br /> <div id="author-info"><br /> <div id="author-avatar"><br /> <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyeleven_author_bio_avatar_size', 60 ) ); ?><br /> </div><!-- #author-avatar --><br /> <div id="author-description"><br /> <?php the_author_meta( 'first_name' ); ?> <?php the_author_meta( 'user_lastname' ); ?> <?php the_author_meta( 'description' ); ?><br /> </div><!-- #author-description --><br /> </div><!-- #entry-author-info --><br /> <?php endif; ?> <!-- / About author -->