• Hey, i’m having a problem to get more than 10 posts on a categorytemplate
    this is the code what i’m using for my Category-template:

    <?php get_header(); ?>
    <?php include(TEMPLATEPATH . '/glossarheader.php'); ?>
    	<div id="content" class="full-width">
    		<div class=glossaraz>
    		<?php if( have_posts() ) : ?>
    <!-- Your list of posts -->
    		<ul>
    			<?php while ( have_posts() ) : the_post(); ?>
    			<li><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3></li>
    			<?php endwhile; ?>
    		</ul>
    		<?php rewind_posts(); // second <del>verse</del> query, same as the first ?>
    		<?php while( have_posts() ) : the_post(); ?>
    		<?php endwhile; endif; ?>
    		</div>
    	</div>
    <?php get_footer(); ?>

    Can somebody give me a tip how i can fix that problem?!?!????
    I’ve already tried another snippet, but that one was just working with the id not with the current pagecategory

    Hope you can help me!
    greetings Toni

Viewing 10 replies - 1 through 10 (of 10 total)
  • just login into WP-Admin and go to Settings –> Reading –> change Blog pages show at most to how many post (change the value you want here)

    Moderator keesiemeijer

    (@keesiemeijer)

    Or try setting the number of posts you want in your theme’s functions.php:

    function my_post_queries( $query ) {
      // not an admin page and is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_category()){
          $query->set('posts_per_page', 10);
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

    Just change the number of posts you want to show in $query->set('posts_per_page', 10);

    Thread Starter Tarzan2000

    (@tarzan2000)

    Thanks, but this also changes the normal blog. I just want to change it for the customtemplate. Or is that not possible?

    greetings Toni

    You can do it by creating a custom Category Template for a specific category (if needed else put the below code in archive.php in your theme folder)

    <?php get_header(); ?>
    <?php include(TEMPLATEPATH . '/glossarheader.php'); ?>
    	<div id="content" class="full-width">
    		<div class=glossaraz>
    		<?php query_posts('showposts=5'); if( have_posts() ) : ?>
    <!-- Your list of posts -->
    		<ul>
    			<?php while ( have_posts() ) : the_post(); ?>
    			<li><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3></li>
    			<?php endwhile; ?>
    		</ul>
    		<?php rewind_posts(); // second <del>verse</del> query, same as the first ?>
    		<?php while( have_posts() ) : the_post(); ?>
    		<?php endwhile; endif; ?>
    		</div>
    	</div>
    <?php get_footer(); ?>

    And FYI, => http://codex.wordpress.org/Category_Templates

    Thread Starter Tarzan2000

    (@tarzan2000)

    I’m having already a template! look in the title 🙂 . I just want to show more than 10 posts in my template! I dont know why but wordpress only shows 10 posts in my categorytemplate 🙁

    Moderator keesiemeijer

    (@keesiemeijer)

    Hey you tried with the code i gave or not ? I am giving it again below,

    <?php get_header(); ?>
    <?php include(TEMPLATEPATH . '/glossarheader.php'); ?>
    	<div id="content" class="full-width">
    		<div class=glossaraz>
    		<?php query_posts('showposts=5'); if( have_posts() ) : ?>
    <!-- Your list of posts -->
    		<ul>
    			<?php while ( have_posts() ) : the_post(); ?>
    			<li><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3></li>
    			<?php endwhile; ?>
    		</ul>
    		<?php rewind_posts(); // second <del>verse</del> query, same as the first ?>
    		<?php while( have_posts() ) : the_post(); ?>
    		<?php endwhile; endif; ?>
    		</div>
    	</div>
    <?php get_footer(); ?>

    In the above code i wrote the query to show 5 posts only at the line <?php query_posts(‘showposts=5’); if( have_posts() ) : ?> and you can change the number to what you wish..

    Thread Starter Tarzan2000

    (@tarzan2000)

    It is a categorytemplate – not a pagetemplate. I tried the code of you @wpadvices but it doesnt’t shows the right categories.
    my categorytemplate is for a subcategory and your code also shows the one from the parent category… it doesn’t work for me 🙁

    Where you put the code ?

    Thread Starter Tarzan2000

    (@tarzan2000)

    in my categorytemplate. i made a categorytemplate an then i putted the code inside. probably i have to say, that i used the plugin
    http://wordpress.org/extend/plugins/category-template-hierarchy/
    but just because i have 26 childcategories and every childcategory should have the same template… so its not that easy to do this without creating 26 templates.
    But anyway do you thing its because of the plugin??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Show more than 10 Posts in Categorytemplate’ is closed to new replies.