separate custom template for each Author in wordpress

separate custom template for each Author in wordpress

WordPress tutorial, separate custom template for each Author in wordpress. You can create different template for each wordpress author. You can also create different styling for each of wordpress authors. This is very common requiement of clients that they want different designed pages for each of wordpress users. That can be easily possible.

separate custom template for each Author in wordpress

You just need create author specific page template in wordpress theme. If author name is john then create author-john.php page in wordpress theme and put following code in that file.


<?php
/*
Template Name: John Author
*/
?>
<?php get_header(); ?>

<?php
 /* Queue the first post, that way we know who
 * the author is when we try to get their name,
 * URL, description, avatar, etc.
 *
 * We reset this later so we can run the loop
 * properly with a call to rewind_posts().
 */
 if ( have_posts() )
 the_post();
?>

&nbsp;

// If a user has filled out their description, show a bio on their entries.
if ( get_the_author_meta( 'description' ) ) : ?>
 <div id="entry-author-info">
 <div id="author-avatar">
 <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'J2010_author_bio_avatar_size', 50 ) ); ?>
 </div><!-- #author-avatar -->
 <div id="author-description">
 <h2><?php printf( __( 'About %s', 'J2010' ), get_the_author() ); ?></h2>
 <?php the_author_meta( 'description' ); ?>
 </div><!-- #author-description&nbsp;&nbsp;&nbsp; -->
 </div><!-- #entry-author-info -->
<?php endif; ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Dont forget to add your different style for each of author pages. Just go to pages and create page with name with your author name and choose the page template of your author name and save the page.

separate custom template for each Author in wordpress
separate custom template for each Author in wordpress

If you are knowing the author id then you can create the author-1.php page also and add your different style for each of your wordpress authors.

Create different post styling through CSS to your each of users. If you are having doubts and issues with styling or code then please contact me on purabtech.in. In purabtech.in you will found many use ful wordpress api, tutorials and hacks and articles.

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

One thought on “separate custom template for each Author in wordpress”

Leave a Reply

Your email address will not be published.