Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Problem with pagination... WordPress


The Pagination for this wp site is not functioning properly for the recipe category of posts. The site is at When I click on page #2 or 3, it loads the same posts as page 1 for the recipes. The template is called gravy.

Here is the code for the recipes template:

Template Name: recipes
get_header(); ?>

<div id="content">

<?php query_posts('category_name=recipes'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php include (TEMPLATEPATH . '/loop.php'); ?>
<?php endwhile; ?>
<?php numeric_pagination(); ?>

<?php else : ?>
<?php _e('Not Found','gravy'); ?>

<?php endif; ?>
<?php get_sidebar('recipes'); ?>
<?php get_footer(); ?>

Please let me know if you need any other additional information to help solve this problem ...

Answers (2)


Brandon Dove answers:

change this

<?php query_posts('category_name=recipes'); ?>

to this

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;


Justin Tadlock answers:

Assuming your `numeric_pagination()` function works correctly, you would only need to change one line of code.

This line:

<?php query_posts('category_name=recipes'); ?>

Should be:

<?php query_posts( array( 'category_name' => 'recipes', 'paged' => $paged, 'posts_per_page' => get_option( 'posts_per_page' ) ) ); ?>