在这里有人的帮助下,我能够通过这个重写规则过滤两个或两个以上的类别。
'^combine/([^/]*)/?([^/]*)/([^/]*)/?','index.php?category_name=$matches[1]+$matches[2]+$matches[3]', 'top'所以如果我能
/combine/michelin/tires/cars/我可以过滤的类别‘汽车’,也有‘轮胎’作为一个类别,也有‘米其林’作为一个类别。
问题是当我尝试使用分页时。我有一个重写规则(放在另一个规则之前)
'^combine/([^/]*)/([^/]*)/([^/]*)/page/([0-9]{1,}/?当我访问这个页面时,它给我的是Not所得住/合并/米其林/轮胎/汽车/页/2/有什么想法吗?,'index.php?category_name=$matches[1]+$matches[2]+$matches[3]&paged=$matches[4]', 'top'当我访问这个页面时,它给我的是Not所得住/合并/米其林/轮胎/汽车/页/2/
有什么想法吗?
发布于 2023-04-24 14:37:15
我按照以下顺序解决了这些重写问题。
因此,我在开头指定了3个类别url,然后在其下面指定了2个类别url,并在和单个类别url中指定了
/combine/brand/category1/category2/page/1-9/
add_rewrite_rule(
'^combine/([^/]*)/([^/]*)/([^/]*)/page/([0-9]*)$/','index.php?category_name=$matches[1]+$matches[2]+$matches[3]&paged=$matches[4]', 'top'
);
/combine/brand/category1/page/1-9
add_rewrite_rule(
'^combine/([^/]*)/([^/]*)/page/([0-9]*),'index.php?category_name=$matches[1]+$matches[2]&paged=$matches[3]', 'top'
);
/combine/brand/category1/
add_rewrite_rule(
'^combine/([^/]*)/?([^/]*)/([^/]*)/?','index.php?category_name=$matches[1]+$matches[2]+$matches[3]', 'top'
);https://wordpress.stackexchange.com/questions/415574
复制相似问题