• Hi,

    I’m trying to create custom author pages with two loops using author.php. I’m using two loops: the first to show the excerpt of the most recent post, the second to display a list of other posts.

    My problem is that ALL authors posts are being displayed/listed. I would like only one.

    Help please!
    Example page: Craig on the Indie Travel Podcast

    My code follows:

    <?php
    global $wp_query;
    $curauth = $wp_query->get_queried_object();
    ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : ?>
    
    		 <?php $post = $posts[0];  ?>
    		<?php if (is_author()) { ?>
    		<h2>Author profile: <?php echo $curauth->nickname; ?></h2>
    		<?php
    		$default = "https://indietravelpodcast.com/images/no_gravatar.jpg"; // link to your default avatar
    		$size = 100; // size in pixels squared
    		$grav_url = "https://www.gravatar.com/avatar.php?gravatar_id=" . md5(trim($curauth->user_email)) . "&default=" . urlencode($default) . "&size=" . $size;
    		?>
    		<a href="<?php echo $curauth->user_url; ?>"><img width="<?php echo $size; ?>" height="<?php echo $size; ?>" src="<?php echo $grav_url; ?>" alt="<?php echo $author_name; ?>" title="<?php echo $author_name; ?>" class="authorgravatar" /></a>
    
    		<p class="authorprofile"><?php echo $curauth->description; ?></p>
    		<?php } ?>
    
    		<div class="clear"></div>
    
    <!-- first loop -->
    		<?php query_posts('showposts=1'); ?>
    		<?php while (have_posts()) : the_post(); ?>
    
    		<div class="post">
    				<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Most Recent: <?php the_title(); ?></a></h2>
    				<small><?php the_time('l, F jS, Y') ?></small>
    
    				<p><?php the_excerpt(); ?></p>
    
    			</div>
    
    		<?php endwhile; ?>
    <!-- second loop -->
    		<h2>More articles by <?php echo $curauth->nickname; ?></h2>
    		  <?php rewind_posts(); ?>
    		  <?php query_posts('showposts=10'); ?>
    
    		  <?php while (have_posts()) : the_post(); ?>
    
    			 <div>
    			 <ul>
    				<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    				<small><?php the_time('l, F jS, Y') ?></small>
    			</ul>
    			</div>
    
    		  <?php endwhile; ?>

    Thanks in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Author.php displaying posts from ALL authors.’ is closed to new replies.