This tutorial explains how to make a author page (author.php) and  what happens when the blog viewer is visiting one of your site’s author pages.  There are many ways that you can modify the look of your author pages. WordPress tags and little bit css make it easy to customize your author page.

If you are going to use author pages, you will probably want to make sure that when a post is displayed, it comes with a link to the author page. You can generate this link, within The Loop, by using the the_author_posts_link Template Tag.


For example:

<p>Author:
<?php the_author_posts_link(); ?></p>

Copy archive.php and rename it author.php

In order to display author information on your author page, you need to edit your author template file(author.php).So that it display which author is being viewed, and retrieves all the information about the author from the database.

First delete  this code from author.php :

<?php if (have_posts()) : ?>

<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

<?php /* If this is a category archive */ if (is_category()) { ?>

<h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>

<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>

<h2 class="pagetitle">Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2>

<?php /* If this is a daily archive */ } elseif (is_day()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>

<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>

<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>

<?php /* If this is an author archive */ } elseif (is_author()) { ?>

<h2 class="pagetitle">Author Archive</h2>

<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>

<h2 class="pagetitle">Blog Archives</h2>

<?php } ?>

And paste this code :

<?php

if(isset($_GET['author_name'])) :

$curauth = get_userdatabylogin($author_name);

else :

$curauth = get_userdata(intval($author));

endif;

?>

Now put this code for author box on the top of the page:

<div>

<?php echo get_avatar( get_the_author_email(), $size = '100'); ?>

<div>

<h2>About: <?php echo $curauth->display_name; ?></h2>

<dl>

<dt>Website</dt>

<dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>

<dt>Email</dt>

<dd><a href="<?php echo $curauth->user_email; ?>"><?php echo $curauth->user_email; ?></a></dd>

<dt>Profile</dt>

<dd><?php echo $curauth->user_description; ?></dd>

</dl>

</div><!--authortext-->

</div><!--/authorbox-->

With the above code make a box with author gravatar, author name, author website, author email and author description.

If you want to display the author post list…

Put this code :

<h2>Posts by <?php echo $curauth->display_name; ?>:</h2>

<ul>

<!-- The Loop -->

<?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; ?>

<!-- End Loop -->

</ul>

It will show author all posts by title, by date and the category posted in.

Here is the complete author page code. You can use this code for your author page.

<?php

/**

* @package WordPress

* @subpackage Default_Theme

*/

get_header();

?>

<div id="content">

<div class="narrowcolumn">

<!-- This sets the $curauth variable -->

<?php

if(isset($_GET['author_name'])) :

$curauth = get_userdatabylogin($author_name);

else :

$curauth = get_userdata(intval($author));

endif;

?>

<div>

<?php echo get_avatar( get_the_author_email(), $size = '100'); ?>

<div class="authortext">

<h2>About: <?php echo $curauth->display_name; ?></h2>

<dl>

<dt>Website</dt>

<dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>

<dt>Email</dt>

<dd><a href="<?php echo $curauth->user_email; ?>"><?php echo $curauth->user_email; ?></a></dd>

<dt>Profile</dt>

<dd><?php echo $curauth->user_description; ?></dd>

</dl>

</div><!--authortext-->

</div><!--/authorbox-->

<h2>Posts by <?php echo $curauth->display_name; ?>:</h2>

<ul>

<!-- The Loop -->

<?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; ?>

<!-- End Loop -->

</ul>

</div><!--narrowcolumn-->

<?php get_sidebar(); ?>

<div class="clear"></div>

</div> <!--/ content-->

<?php get_footer(); ?>

CCS for this author page :

/*----Authore Info box---*/

#author_box{

background:#EFEFEF;

border:1px solid #CECFD0;

width:580px;

margin:10px 0px 0px 0px;

margin-bottom:10px;

overflow:hidden;

padding:5px;

}

#author_box h4{

font-size:16px;

color:#191919;

margin:0;

padding:10px 10px 5px 10px;

}

.author_text{

padding-left:100px;

}

#author_box img {

border:1px solid #990000;

float:left;

margin:10px;

padding:10px;

}

#author_box p{

color:#191919;

margin:0;

padding:0px 10px 10px 10px;

}

#author_box h4 > a{

text-decoration:none;

}

#author_box p{

color:#191919;

}

You can modify the CSS file to match your theme.

That’s all.

Categories: Wordpress

About


Notice: the_author_description is deprecated since version 2.8.0! Use the_author_meta('description') instead. in /home/greetbpn/public_html/gopalbonline.com/wp-includes/functions.php on line 3839
He is a freelance graphic designer with more than 15 years of design experience, including both print and web design.

.. Write a Guest Post ..


5 Responses so far.


  1. spectrum_arklights says:

    the tutorial is really nice and helpful.

  2. Ballari says:

    Very Interesting…
    The tutorial is extremely helpful.

  3. jayanti says:

    Quite helpful, Thanks.

  4. nigel says:

    Good tutorial.. thanks…

  5. I have been struggling with this thanks for the tutorial

Copyright © 2018 gopalbonline.com