0

I have a problem with the Woocommerce Pagination but only on the Search Page. On category sites the pagination links are working just fine.

But on the Search Page the pagination generates links like this:

"/page/2/?s=adalya&post_type=product"

Even though this url does not work but it displays the root url of my domain and does not generate a 404 not found error.

I would like to change the whole search URL structure to something like:

"/search/search-query/2"

My Pagination links

<nav class="woocommerce-pagination">
    <?php
        $pages = paginate_links( apply_filters( 'woocommerce_pagination_args', array( // WPCS: XSS ok.
            'base'      => $base,
            'format'    => $format,
            'add_args'  => false,
            'current'   => max( 1, $current ),
            'total'     => $total,
            'prev_text' => '<i class="icon-angle-left"></i>',
            'next_text' => '<i class="icon-angle-right"></i>',
            'type'      => 'array',
            'end_size'  => 3,
            'mid_size'  => 3,
        ) ) );

        if ( is_array( $pages ) ) {
            $paged = ( get_query_var( 'paged' ) == 0 ) ? 1 : get_query_var( 'paged' );
            echo '<ul class="page-numbers nav-pagination links text-center">';
            foreach ( $pages as $page ) {
                $page = str_replace( 'page-numbers', 'page-number', $page );
                echo '<li>' . $page . '</li>';
            }
            echo '</ul>';
        }
    ?>
</nav>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.