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.

Some best WordPress Hacks for theme developer

there are many wordpress theme deverlopers who are looking for wordpress hacks for theme developer. we have best collection of wordpress hacks for theme developer. Some best WordPress Hacks for theme developer.

wordpress hacks for theme developer

 wordpress hacks for theme developer
wordpress hacks for theme developer

WordPress themes market has grown incredibly. Due to lot of amazing new functionality an synchronization with all social sites.

1. Create TinyURLs with your wordpress site
Open your single.php file and paste the following in the loop:


<?php
echo 'Tiny Url for this post: <a href="'.bloginfo('siteurl').'?p=.'$post->ID.'">'.bloginfo('siteurl').'?p=.'$post->ID.'</a>'
?>

2. Use The Loop To Create An “Archive” Page Template

Create the php page called archive.php and create archive page through wordpress admin and select the archive page template from sidebar option.

In archive.php file you can following code:

<?php
/*
Template Name: Archives
*/
?>

<?php get_header(); ?>

<h2><?php $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts); ?>
<h2><?php echo $numposts.' recipes published since October 06, 2008'; ?>
</h2>

<ul id="archive-list">
<?php
$myposts = get_posts('numberposts=-1&');
foreach($myposts as $post) : ?>
<li><?php the_time('m/d/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

3. Create A “Share the article with Facebook” Button
Use the following code in your loop where you want show the facebook share button.

<a href="http://www.facebook.com/sharer.php?u=<?php get_permalink();?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a>

4. Use More Than One Loop On A Page, Without Printing Duplicate Posts

If you want to use two query post in page or post. you can use following code:

<?php
query_posts('showposts=8');
$ids = array();
while (have_posts()) : the_post();
$ids[] = get_the_ID();
the_title();
the_content();
endwhile;
?>

<?php
query_posts(array('post__not_in' => $ids));
while (have_posts()) : the_post();
the_title();
the_content();
endwhile;
?>

5. Insert Ads After The First Post
If you want show the ad after first post then use the following code:

<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count == 2) : ?>
//Paste your ad code here
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php else : ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>

There are so many wordpress tricks and hack you can found in this website. Search more.