Wordpress 我可以将带有查询参数的存档页面URL更改为带有斜杠的URL吗
我想更改wordpress网站中自定义分类法归档页面的URL 现在,我使用查询字符串来构建每个分类法归档页面Wordpress 我可以将带有查询参数的存档页面URL更改为带有斜杠的URL吗,wordpress,.htaccess,mod-rewrite,url-rewriting,Wordpress,.htaccess,Mod Rewrite,Url Rewriting,我想更改wordpress网站中自定义分类法归档页面的URL 现在,我使用查询字符串来构建每个分类法归档页面 example.com/customeposttype/?genre=bbq 如果用户请求上述URL,将显示bbq的分类归档 现在我想强制URL如下所示 example.com/customeposttype/genre/bbq/ 页面内容应与中的内容相同 “example.com/customeposttype/?流派=烧烤” 是否可以使用add\u rewrite\u rule()或
example.com/customeposttype/?genre=bbq
如果用户请求上述URL,将显示bbq的分类归档
现在我想强制URL如下所示
example.com/customeposttype/genre/bbq/
页面内容应与中的内容相同
“example.com/customeposttype/?流派=烧烤”
是否可以使用add\u rewrite\u rule()
或向.htaccess
添加一些代码来重写URL
我尝试了下面的代码,但没有成功
function my_custom_rewrite() {
add_rewrite_rule(
'^/shop/(\w+)/?',
'index.php/shop/?genre=$matches[1]',
'top'
);
}
add_action('init', 'my_custom_rewrite');
尝试使用Wp admin permalink设置您可以尝试使用自定义permalink: 喜欢:/shop/%genre%