Author template – the_author_posts to appear ONCE
I am designing an author template and it goes like this:
<?php if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif; $authid = $curauth->ID; ?> <h2 class="author"><?php _e($curauth->first_name); ?> <?php _e($curauth->last_name); ?></h2> <ul class="authdesc"> <li><strong><?php _e($curauth->professional_title); ?></strong></li> <li><strong>E-Mail:</strong> <?php _e($curauth->user_email); ?></li> <li><strong>Website:</strong> <a href="<?php _e($curauth->user_url); ?>"><?php _e($curauth->user_url); ?></a></li> <li><strong>Profile:</strong> <?php _e($curauth->description); ?></li> </ul> <h3><?php echo $curauth->nickname; ?> has written <?php the_author_posts(); ?> Articles:</h3> <!-- The Loop Begins--> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Here’s the trouble – I would like the author nickname & number of posts they have written to only appear once at the top of the author page, but this template tag says that it needs to be within the loop. I don’t want it showing up at the top of every post on the author template, just the one time at the top. I’ve tried to add another loop and just query one post and display this line one time but the second loop gets messed up.
How can I call the number of author posts just once at the top of the template? (It appears to be accurate until I start looking at other authors who have written 0 posts, and it’s got the total number of posts written displayed)
- The topic ‘Author template – the_author_posts to appear ONCE’ is closed to new replies.