WordPress.org

Forums

Custom template - Display x posts per page and add paged naviation? (2 posts)

  1. corienb
    Member
    Posted 2 years ago #

    I made a custom template page (thanks to someone else here for the code) that displays only posts with category ID 20 on the page. In this case anything with the category of 'blog'

    <?php /*
    Template Name: Blog Posts only
    */ ?>
    
    <?php get_header(); ?>
    <div  id="primary">
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<h1><?php the_title(); ?></h1>
    		<?php the_content(); ?>
    	<?php endwhile; else: endif; ?>
    
    	<?php query_posts('cat=20'.get_the_title().'&post_status=publish,future');?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    	<?php the_content(); ?>
        <div class="blogartikelnext"></div>
    	<?php endwhile; else: endif; ?>
    </div> 
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?></div>

    How do I add code so it shows x (say, 3 ) posts per page, and have it add 'older posts' and 'newer posts' navigation links at the bottom?

    Thanks!!

  2. DaveCoast
    Member
    Posted 2 years ago #

    Pagination is not available with query_posts you need to use WP_Query.

    Class_Reference/WP_Query

Topic Closed

This topic has been closed to new replies.

About this Topic