• Resolved swollenpickles

    (@swollenpickles)


    I’m trying to figure out how to specify how to display a set number of posts on the category pages of my site (a different number to that displayed on the home page).

    For example, in the reading tab I’ve set the number of posts to appear on the homepage to 5, however on the category pages I want to display 12 posts per page. I’ve tried implementing a fix in my archive.php file but it aint working. I used query_posts(‘posts_per_page=12’ but I don’t think I’ve done it right. Can any one help me get it working? Any help is appreciated.

    Here is my current archive.php page I’m working with:

    <?php get_header(); ?>
    
    	<div id="content">
    
    		<?php query_posts('posts_per_page=12');
    		if (have_posts()) : ?>
    
     	  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
     	  <?php /* If this is a category archive */ if (is_category()) { ?>
    		<h2 class="pagetitle">Browsing images from the <?php single_cat_title(); ?> category</h2>
     	  <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    		<h2 class="pagetitle">Posts Tagged ‘<?php single_tag_title(); ?>’</h2>
     	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    		<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
     	  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    		<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
     	  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    		<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
    	  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    		<h2 class="pagetitle">Author Archive</h2>
     	  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    		<h2 class="pagetitle">Blog Archives</h2>
     	  <?php } ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<?php $thumb_gallery = get_post_meta($post->ID, 'thumbnail-gallery', $single = true); ?>		
    
    		<div id="tb-gal">
    			<div id="tb-gal-con">
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    				<?php // if there's a thumbnail
    					if($thumb_gallery !== '') { ?>
    						<p>
    							<img src="<?php echo $thumb_gallery; ?>" />
    						</p>
    				<?php } ?>
    			</a>
    			</div>
    			<div id="tb-title">
    				<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title_attribute(); ?></a>
    			</div>
    		</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<?php
    				include('wp-pagenavi.php');
    				if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    			?>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_footer(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Setting number of posts per category page’ is closed to new replies.