Forums

[resolved] conditional archive with different number of posts displayed (3 posts)

  1. Pete
    Member
    Posted 2 years ago #

    I've got the below code... it has a condition whereby if the archive is by month then it displays the list of posts differently.

    Here's my issue... I'd like to display this list of posts (by month) of 50 at a time, despite the wordpress settings being 10. I want to keep it as 10 for the other archives, just 50 for the by month archives... clear as mud?

    Thanks heaps

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php if (is_month()) { ?>
    			<li style="margin-left:30px;list-style-type:square;"><?php the_time('F j, Y'); ?> &middot; <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> &middot; <a rel="nofollow" href="<?php the_permalink(); ?>#respond"><span class="icomment"></span></a> <a rel="nofollow" href="<?php the_permalink(); ?>#respond"><?php comments_number(__('', 'studiopress'), __('1 Comment', 'studiopress'), __('% Comments', 'studiopress')); ?></a></li>
    <?php } else { ?>
    
    			<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    
    			<div class="date">
    				<p><span class="time"><?php the_time('F j, Y'); ?></span> &middot; <span class="icomment"><a rel="nofollow" href="<?php the_permalink(); ?>#respond"><?php comments_number(__('Leave a Comment', 'studiopress'), __('1 Comment', 'studiopress'), __('% Comments', 'studiopress')); ?></a></span>&nbsp;<?php edit_post_link(__('(Edit)', 'studiopress'), '', ''); ?></p>
    			</div>
    
    			<?php the_excerpt();?><div class="clear"></div>
    
    			<div class="postmeta2">
                    <p><?php _e("Filed under", 'studiopress'); ?> <?php the_category(', ') ?></p>
                </div>
    <?php } ?>
    			<?php endwhile; else: ?>
  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    before your code, add:

    <?php if (is_month()) {
    global $query_string;
    query_posts($query_string . "&posts_per_page=50"); } ; ?>

    should work, not tested ;-)

  3. Pete
    Member
    Posted 2 years ago #

    Works great... thanks heaps.

Topic Closed

This topic has been closed to new replies.

About this Topic