Skip to main content
added 294 characters in body
Source Link
user10106
user10106

I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query to display a heading as such:

showing x of y results for ...

and the code:

elseif ($size_option&&!$color_option&&!$genre_option) {
echo '<h3>Showing ' . $wp_query->post_count . ' of ' . $wp_query->found_posts . '    results for ' . $size_name . ', all colors, all genres</h3>';}

As such it will show something like - showing 12 of 17 results for ...

However the issue is i have my posts_per_page set to 12. So when i go to page 2 (for a query that results in found_posts being 17), we get - showing 5 of 17 results for ...

Which is just illogical.

My question is how could i get it to show the following for once again, a total of 17 posts:

On page 1 - showing 1-12 of 17 results for...

On page 2 - showing 13-17 of 17 results for...

I have an idea of what i should use, but no idea on how to go about it. Im guessing i need to implement some kind of count, based on the 'paged'=> $paged arg from my wp_query.

Any help would be wondeful. Thank you, once again!

Mike

as requested by Johannes, my query :

$wp_query = new WP_Query ( array(
                                'post_type' => 'tshirt',
                                'posts_per_page' => 12,
                                'paged'=> $paged,
                                'colors' => $color_option,
                                'size' => $size_option,
                                'genres' => $genre_option));

I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query to display a heading as such:

showing x of y results for ...

and the code:

elseif ($size_option&&!$color_option&&!$genre_option) {
echo '<h3>Showing ' . $wp_query->post_count . ' of ' . $wp_query->found_posts . '    results for ' . $size_name . ', all colors, all genres</h3>';}

As such it will show something like - showing 12 of 17 results for ...

However the issue is i have my posts_per_page set to 12. So when i go to page 2 (for a query that results in found_posts being 17), we get - showing 5 of 17 results for ...

Which is just illogical.

My question is how could i get it to show the following for once again, a total of 17 posts:

On page 1 - showing 1-12 of 17 results for...

On page 2 - showing 13-17 of 17 results for...

I have an idea of what i should use, but no idea on how to go about it. Im guessing i need to implement some kind of count, based on the 'paged'=> $paged arg from my wp_query.

Any help would be wondeful. Thank you, once again!

Mike

I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query to display a heading as such:

showing x of y results for ...

and the code:

elseif ($size_option&&!$color_option&&!$genre_option) {
echo '<h3>Showing ' . $wp_query->post_count . ' of ' . $wp_query->found_posts . '    results for ' . $size_name . ', all colors, all genres</h3>';}

As such it will show something like - showing 12 of 17 results for ...

However the issue is i have my posts_per_page set to 12. So when i go to page 2 (for a query that results in found_posts being 17), we get - showing 5 of 17 results for ...

Which is just illogical.

My question is how could i get it to show the following for once again, a total of 17 posts:

On page 1 - showing 1-12 of 17 results for...

On page 2 - showing 13-17 of 17 results for...

I have an idea of what i should use, but no idea on how to go about it. Im guessing i need to implement some kind of count, based on the 'paged'=> $paged arg from my wp_query.

Any help would be wondeful. Thank you, once again!

Mike

as requested by Johannes, my query :

$wp_query = new WP_Query ( array(
                                'post_type' => 'tshirt',
                                'posts_per_page' => 12,
                                'paged'=> $paged,
                                'colors' => $color_option,
                                'size' => $size_option,
                                'genres' => $genre_option));
Source Link
user10106
user10106

Having a variable based on $post_count increase when i move to the next page of results

I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query to display a heading as such:

showing x of y results for ...

and the code:

elseif ($size_option&&!$color_option&&!$genre_option) {
echo '<h3>Showing ' . $wp_query->post_count . ' of ' . $wp_query->found_posts . '    results for ' . $size_name . ', all colors, all genres</h3>';}

As such it will show something like - showing 12 of 17 results for ...

However the issue is i have my posts_per_page set to 12. So when i go to page 2 (for a query that results in found_posts being 17), we get - showing 5 of 17 results for ...

Which is just illogical.

My question is how could i get it to show the following for once again, a total of 17 posts:

On page 1 - showing 1-12 of 17 results for...

On page 2 - showing 13-17 of 17 results for...

I have an idea of what i should use, but no idea on how to go about it. Im guessing i need to implement some kind of count, based on the 'paged'=> $paged arg from my wp_query.

Any help would be wondeful. Thank you, once again!

Mike