create author page template in wordpress theme

create author page template in wordpress theme

We have many guest authors who writes in our blogs. So creating author page is good idea. Here in this article we created author page template in wordpress theme. There are many wordpress plugins available which will give you facility to show author list.

Without wordpress plugin show author list

Here we created simple wordpress page template for showing author list in wordpress website. we created authorlist.php file in wordpress theme folder and added following code in that file.


<?php
/*
Template Name: AuthorList
*/

get_header(); ?>

&nbsp;&nbsp; &nbsp;<div id="primary" class="content-area clr">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<div id="content" class="site-content left-content" role="main">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<div id="authorlist"><ul><?php contributors(); ?></ul></div>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</div><!-- #content -->
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<?php get_sidebar(); ?>
&nbsp;&nbsp; &nbsp;</div><!-- #primary -->
<?php get_footer(); ?>

 

Open your functions.php file and put following contributors function in that file.

 


function contributors() {
global $wpdb;

$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY user_registered");

foreach ($authors as $author) {

echo "<li>";
echo "<a href=\"" . get_bloginfo('url') . "/author/";
the_author_meta('user_nicename', $author->ID);
echo "/\">";
echo get_avatar($author->ID);
echo "</a>";
echo '<div>';
echo "<a href=\"" . get_bloginfo('url') . "/author/";
the_author_meta('user_nicename', $author->ID);
echo "/\">";
the_author_meta('display_name', $author->ID);
echo "</a>";
echo "<br />";
echo "Website: <a href=\"";
the_author_meta('user_url', $author->ID);
echo "/\" target='_blank'>";
the_author_meta('user_url', $author->ID);
echo "</a>";
echo "<br />";
echo "Twitter: <a href=\"http://twitter.com/";
the_author_meta('twitter', $author->ID);
echo "\" target='_blank'>";
the_author_meta('twitter', $author->ID);
echo "</a>";
echo "<br />";
echo '<div >';
the_author_meta('description', $author->ID);
echo '</div>';

echo "<br />";
echo "<a href=\"" . get_bloginfo('url') . "/author/";
the_author_meta('user_nicename', $author->ID);
echo "/\">Visit&nbsp;";
the_author_meta('display_name', $author->ID);
echo "'s Profile Page";
echo "</a>";
echo "</div>";
echo "</li>";
}
}

add above code in functions.php file. You can change styling as per your website code.

 create author page template in wordpress theme

Now login to wordpress admin panel and go to pages. Create new page called “Author List”. From Page Attributes section you need to select Template.

create author page template in wordpress theme
create author page template in wordpress theme

 

As per shown in above Image. You need select “AuthorList” in Template DropDown and save the page. Than add Authorlist page add in menu. Now you are able to see the Authorlist without extra wordpress plugin.

If you want to add JavaScript and CSS in page template page than refer our article. You can create contact us page template using similar type of code.

 

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.