WordPress使用功能文件中的重写规则重写URL。

时间:2019-01-05 12:55:16

标签: wordpress url-rewriting

我正在尝试为我的项目创建SEO友好的网址。

我有一个网址带有不同的参数。如何使用重写规则进行重定向。

例如。 529 chlid页面网址的ID。 433个ID产品页面网址。

function custom_rewrite_tag(){

add_rewrite_tag('%title%','([^&]+)');
add_rewrite_tag('%categroy%','([^&]+)');
add_rewrite_tag('%sub_cate_name%','([^&]+)');

} add_action('init','custom_rewrite_tag',10,0);

function custom_rewrite_rule(){     add_rewrite_rule('^ products /([^ /] *)/?','index.php?page_id = 529&title = $ matches [1]','top');

add_rewrite_rule('^products/([^/]*)/([^/]*)/?','index.php?page_id=433&categroy=$matches[1]&sub_cate_name=$matches[2]','top');

} add_action('init','custom_rewrite_rule',10,0);

在这种情况下,它仅使用第一个规则。如何为同一页面网址实施两个规则。

0 个答案:

没有答案