Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112476

aweisman on "Changing posts_per_page for first of paginated pages"

$
0
0

Hello! I'm a little stumped with a pagination issue.

I've been using the kriesi_pagination() function for all of my pagination and it's worked great. Currently, however, I need to paginate a gallery that will have a certain number of posts on the first page, and a different number on the following pages.

i.e.

if($paged > 1){
	$posts_per_page = 24;
} else {
	$posts_per_page = 15;
}

And then I would pass these args to WP_Query...

'posts_per_page' => $posts_per_page,
'paged' => $paged

The problem I'm running into is that when I get to the second page, the counts are off. Let's say I have 17 posts. Since the posts_per_page on page 2 is 24, it's not going to start at 16 (showing 16 and 17), it's going to start at 25 (showing nothing).

I had a look at using offset, but it looks like setting that causes the 'paged' parameter to be ignored (per the codex). I'm not sure how to proceed. The only thing I can think to do now is to work with offset to create my own pagination. I guess I just wanted to check here first to see if anyone had any thoughts on using 'paged' and 'posts_per_page' to get this working, or any tips on other solutions.

Thanks so much for your time!!


Viewing all articles
Browse latest Browse all 112476

Trending Articles