I implemented a pagination using paginate_links()
like below:
<?php
function wpse229670_pagination( $query = false ) {
global $wp_query;
$query = $query ? $query : $wp_query;
$total_pages = $query->max_num_pages;
$big = 999999999;
if ( $total_pages > 1 ) {
echo '<nav class="navigation posts-navigation" role="navigation">';
echo '<strong>'. __( 'Pages:', 'text-domain' ) .'</strong> ';
echo paginate_links( array(
'base' => ,
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $total_pages
) );
echo '</nav>';
} //endif ( $total_pages > 1 )
}
And I can easily display my pagination using wpse229670_pagination();
within loop, or for any custom loop, I can pass the local query as a parameter.
It's working fine.
Scenario is, I'm adding some query args like this to display a modal warning to the user:
$terms = wp_get_post_terms( $post_id, 'my_tax' );
$term_link = get_term_link( $term_id, 'my_tax' );
$parameterized_url = add_query_arg( 'from_expired', 1, $term_link );
wp_redirect($parameterized_url);
exit;
But the pagination links continue to display the warning, as because I cannot remove_query_arg()
from the query and the following pages contains the argument as well.
I think it would be better if I can remove necessary [one time] query_args inside my pagination function. You know I cannot do:
//$query = remove_query_arg( 'from_expired', $query );
because $query
inside my function is an object.
So, how can I remove_query_arg()
from a $wp_query
object or from paginate_links()
?