The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Author template - the_author_posts to appear ONCE (1 post)

  1. intricateartist
    Posted 3 years ago #

    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));
      $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>
    <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)


Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by intricateartist
  • This topic is not resolved
  • WordPress version: 3.4.2