我遇到了woocommerce分页的问题,但我无法解释,您可以在网站中重现错误。转到此链接并滚动直到分页,然后尝试单击其中一个分页链接。您将看到它重定向到404页面,并将page/XX/
添加到网址的末尾。
例如,数字2中的网址是:
http://alibabaonline.com.co/categoria-producto/juguetes/anillos-estimulantes/page/2/medellin
但是当您点击该号码时,该网址会重定向到404页面并添加此新网址:
http://alibabaonline.com.co/categoria-producto/juguetes/anillos-estimulantes/page/2/page/2/medellin/page/2/
所以,正如你所看到的,我还添加了额外的参数'在这个例子中,城市的名称是麦德林,为了做到这一点,我重写了网址,这就是我正在做的事情:
function custom_rewrite_basic() {
add_rewrite_rule('^tienda/page/?([0-9]{1,})/([^/]+)/?$','index.php?post_type=product&paged=$matches[1]&ciudad=$matches[2]', 'top');
add_rewrite_rule('^blog/page/?([0-9]{1,})/([^/]+)/?$','index.php?category_name=blog&paged=$matches[1]&ciudad=$matches[2]', 'top');//Paginación
add_rewrite_rule('^tienda/(.+?)/([^/]+)/([^/]+)/?$','index.php?page=tienda&product_cat=$matches[1]&product=$matches[2]&ciudad=$matches[3]', 'top'); //Para detalle producto
add_rewrite_rule('^categoria-producto/(.+?)/page/?([0-9]{1,})/([^/]+)/?$','index.php?product_cat=$matches[1]&paged=$matches[2]&ciudad=$matches[3]', 'top');//Paginación
add_rewrite_rule('^categoria-producto/(.+?)/([^/]+)/?$','index.php?product_cat=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt productCat/medellin
add_rewrite_rule('([^/]+)/?$','index.php?ciudad=$matches[1]', 'top'); // Para index/ciudad
add_rewrite_rule('([^/]*)?/([^/]+)/?$','index.php?pagename=$matches[1]&ciudad=$matches[2]', 'top'); // Para pagina/ciudad
add_rewrite_rule('^tiendas/([^/]+)/?$','index.php?post_type=tiendas&ciudad=$matches[1]', 'top'); //Para cpt tiendas/medellin
add_rewrite_rule('^catalogo/([^/]+)/?$','index.php?post_type=catalogo&ciudad=$matches[1]', 'top'); //Para cpt catalogo/medellin
add_rewrite_rule('^catalogo/([^/]+)/([^/]+)/?$','index.php?post_type=catalogo&catalogo=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt single/catalogo
add_rewrite_rule('^cat_marcas/([^/]+)/([^/]+)/?$','index.php?cat_marcas=$matches[1]&ciudad=$matches[2]', 'top'); //Para cpt marcas/medellin
add_rewrite_rule('^search/(.+)/([^/]+)/?$','index.php?s=$matches[1]&ciudad=$matches[2]', 'top'); //Para buscador
add_rewrite_rule('^blog/([^/]+)/?$','index.php?category_name=blog&ciudad=$matches[1]', 'top'); //Para la categoría blog/ciudad
add_rewrite_rule('^blog/([^/]+)/([^/]+)/?$','index.php?category_name=blog&category_name=$matches[1]&ciudad=$matches[2]', 'top'); // Widget categorias
add_rewrite_rule('^blog/page/?([0-9]{1,})/([^/]+)/?$','index.php?category_name=blog&paged=$matches[1]&ciudad=$matches[2]', 'top'); //Para la paginacion blog/ciudad
add_rewrite_rule('([^/]+)?/([^/]+)/?$','index.php?name=$matches[1]&ciudad=$matches[2]', 'top'); //Para el nombreDeLaEntrada/ciudad
}
add_action('init', 'custom_rewrite_basic');
我用来进行分页的重写规则是:
add_rewrite_rule('^categoria-producto/(.+?)/page/?([0-9]{1,})/([^/]+)/?$','index.php?product_cat=$matches[1]&paged=$matches[2]&ciudad=$matches[3]', 'top');//Paginación
还有一种想法是,在我的本地机器上运行良好。
提前谢谢