0

When I'm on archives pages I am using the code below to query posts. In my theme options to_count_home calls the number of posts.

WordPress isn't generating the correct number of pages based on posts_per_page. Instead it is generating pages based on the number of posts per page I have selected in my default WordPress settings. For example, if I have 10 posts per page in the settings then set posts_per_page in the code as 5, when I go to the second page (which should have 5 posts on it) I get a 404 error.

Here is the code I'm using:

<?php
$per_page = get_option('to_count_home');
query_posts("posts_per_page={$per_page}");
if (have_posts())
?>

1 Answer 1

0

You are not modifying your query, but nuking it completely. Please see query_posts() documentation in Codex on how to correctly re-run query with changed arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.