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

Problem with pagination... WordPress

  • SOLVED

The Pagination for this wp site is not functioning properly for the recipe category of posts. The site is at http://lemonadecleansetogo.com/programs/recipes/ 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:

<?php
/*
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 : ?>
<h2>
<?php _e('Not Found','gravy'); ?>
</h2>

<?php endif; ?>
</div>
<!--/content-->
<?php get_sidebar('recipes'); ?>
<?php get_footer(); ?>


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

Answers (2)

2010-01-26

Brandon Dove answers:

change this

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


to this

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('category_name=recipes&paged='.$paged);
?>

2010-01-26

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' ) ) ); ?>