WordPress remove query vars from $_GET paginate_links

Viewed 79

I have a custom WP AJAX function, which returns WooCommerce products and pagination, the issue is that the links generated by pagination contain the query variables that were sent for the request. How can I disable this feature?

Here's the code for pagination:

 $base =esc_url(get_permalink( wc_get_page_id( 'shop' ) ));

        $pagination = paginate_links( array(
            'base'      => $base . "page/" . '%#%',
            'total'        => $query->max_num_pages,
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'show_all'     => false,
            'type'         => 'list',
            'mid_size'     => 2,
            'prev_next'    => true,
            'prev_text'    => sprintf( '<li>%1$s</li>', __( '←' ) ),
            'next_text'    => sprintf( '<i>%1$s</i>', __( '→' ) ),
            'add_args'     => false,
            'add_fragment' => '',
        ) );

This generated this code:

<ul class="page-numbers">
    <li><span aria-current="page" class="page-numbers current">1</span></li>
    <li><a class="page-numbers" href="https://pirdys.com/shop/page/2?action=woocommerce_products&amp;page=1&amp;is_paginated=true">2</a></li>
    <li><a class="next page-numbers" href="https://pirdys.com/shop/page/2?action=woocommerce_products&amp;page=1&amp;is_paginated=true"><i>→</i></a></li>
</ul>
0 Answers
Related