WordPress.org

Ready to get started?Download WordPress

Forums

Author page listing only 5 posts (2 posts)

  1. Nessdufrat
    Member
    Posted 1 year ago #

    Hi!
    I noticed today that the author pages, where I used the loop to display a list of the author's posts, are showing only the 5 most recent posts.
    I think this is because I specified that on the home page I want only 5 posts displayed, but I'd like to override this for the author's page, and the list of articles I want displayed there.
    I found people posting for the similar questions 6 years ago, and it was solved with a plugin, but of course it's a bit outdated now.

    Here's my code :

    <?php
    /*
    Template Name: Auteur
    */
    get_header(); ?>
    
    <!-- This sets the $curauth variable -->
    
        <?php
        $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
        ?>
    
    <div id="content" class="<?php echo $curauth->user_nicename; ?>">
        <h1><?php echo $curauth->nickname; ?></h1>
        <dl>
            <dt>Site internet : </dt>
            <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
            <dt>Biographie : </dt>
            <dd><?php echo $curauth->user_description; ?></dd>
        </dl>
    
        <h2>Les articles de <?php echo $curauth->nickname; ?> :</h2>
        <ul>
    <!-- The Loop -->
    
        <?php
    	if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <li>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
                <?php the_title(); ?></a>,
                <?php the_time('d M Y'); ?> dans <?php the_category('&');?>
            </li>
    
        <?php endwhile; else: ?>
            <p><?php _e('Aucun article trouv&eacute; pour cet auteur.'); ?></p>
    
        <?php endif; ?>
    
    <!-- End Loop -->
    
        </ul>
    
    <?php
    global $post;
    $author_id=$post->post_author;
    echo get_avatar($author_id, 200);
    ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I don't know how to force the list of all the posts. Maybe with a query_posts?

    Thanks for your advice!

  2. Nessdufrat
    Member
    Posted 1 year ago #

    Sorry, like usual (or almost like usual), I solved it myself.

    So, if anybody is wondering :

    query_posts( $query_string.'&showposts=9999');

    did the trick. Maybe there's something more "elegant"?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags