Opened 2 years ago
Closed 2 years ago
#15962 closed defect (bug) (invalid)
Category 'posts_per_page' being ignored in query_posts when 'Blog pages show at most' set to 10
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 3.0.3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
The scenario for this is as follows:
- Using default category base.
- In 'Appearance -> Reading', 'Blog pages show at most' is set to 10.
- The permalink is accessing the category using it's slug name.
- The category is using a custom 'category-slug.php'.
In the custom category, I have the following code, above the call to 'get_header()'.
global $wp_query; query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => 2, 'posts_per_archive_page' => 2 ) ) );
The first page shows 2 posts when the permalink is '/category/slug/'.
However, when the permalink is '/category/slug/page/2/', the query with the 'posts_per_page' set to 10, and as I only have 4 posts, it shows nothing.
If I set 'Blog shows at most' to something other than 10, it obeys my overridden value.
Change History (2)
Note: See
TracTickets for help on using
tickets.

The request is parsed earlier, so the control doesn't even get to query_posts in this case.
You need to use query_string filter like in Ryan's example, or perhaps use a plugin like Different Posts Per Page.