Bootstrap-wordpress-pagination icon indicating copy to clipboard operation
Bootstrap-wordpress-pagination copied to clipboard

Potential issue with the getting current page var

Open rmorse opened this issue 8 years ago • 0 comments

Hi there,

Just reporting an issue and providing potential fix, I don't have enough time to pull req but would be great if you could include.

Background - I have a plugin that creates custom queries, and one of our users wanted to integrate the results from the query our plugin generates with your pagination.

I took a quick look and I've noticed you have the option to pass in custom_query which looks great and should work, however looking at the code I do see a potential error - on line 26:

$page = intval( get_query_var( 'paged' ) );

You get the current page variable using get_query_var, this function only accesses the global $wp_query so it can in fact (under certain circumstances) be incorrect - as is the case with our plugin.

Something I figured out is that you can get the paged variable directly from the query -

$page = $args['custom_query']->query['paged'];

which I think would cover all use cases.

Anyway would be great to get that change integrated, let me know what you think!

rmorse avatar Nov 16 '16 21:11 rmorse