最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom post types - Woocommerce search pagination not working

programmeradmin2浏览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>
发布评论

评论列表(0)

  1. 暂无评论