Support » Fixing WordPress » Using ‘query_posts’ parameters in author.php

  • Resolved Hedley


    My author.php correctly displays information from the user record and a list of titles of that users posts. This is good. Now I want to limit the post titles that are displayed by excluding two categories, and I also want to force it to display all post titles, instead of the globally set ten posts.

    To my author.php I added (right at the start of the loop): <?php query_posts('showposts=9999&cat=-30,-32'); ?>. It works, in the sense that it excludes the two categories and removes the 10 post limit, BUT, it displays posts from ALL users, not just the one specified in the curauth variable (yet still displays the curauth data for the correct user).

    I assume that use of ‘query_posts’ is overriding the post selection somehow, but I’m at a loss where and how. Can anyone spot the flaw in my usage? Here’s my entire author.php.


    <?php get_header(); ?>
       <div id="content" class="narrowcolumn">
          <!-- This sets the $curauth variable -->
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    <h2>About: <?php echo $curauth->nickname; ?></h2>
    <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
    <dd><?php echo $curauth->user_description; ?></dd>
    <h2>Posts by <?php echo $curauth->nickname; ?>:</h2>
    <!-- The Loop -->
    <?php query_posts('showposts=9999&cat=-30,-32'); ?><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
    <?php the_title(); ?></a>,
    <?php the_time('d M Y'); ?> in <?php the_category('&');?>
      <?php endwhile; else: ?>
         <p><?php _e('No posts by this author.'); ?></p>
    	<?php endif; ?>
    <!-- End Loop -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Try replacing

    <?php query_posts(‘showposts=9999&cat=-30,-32’); ?>


    <?php query_posts($query_string.’&showposts=9999&cat=-30,-32′); ?>

    Just added “$query_string.” and “&” before showposts.

Viewing 1 replies (of 1 total)
  • The topic ‘Using ‘query_posts’ parameters in author.php’ is closed to new replies.