[英]Wordpress Rewrite URL with params
I have the following url and I'm using the type
parameter in a WP_Query
to generate a list of posts. 我有以下网址,并且在WP_Query
使用type
参数来生成帖子列表。
http://wordpress.dev/en-ie/category-holiday-deals/?type=city-breaks
I want to rewrite the url so it looks like this: 我想重写该URL,所以它看起来像这样:
http://wordpress.dev/en-ie/holiday-deals/city-breaks
but I want to be able to use the type
param still. 但我仍然希望能够使用type
param。
I have the following that's capturing the query vars: 我有以下捕获查询变量:
add_filter('query_vars', 'sd_query_vars', 10, 1);
function sd_query_vars($vars) {
$vars[] = 'type';
$vars[] = 'destination';
return $vars;
}
but I can't figure out how to rewrite the URL. 但我不知道如何重写URL。
Any suggestions? 有什么建议么?
Whenever I've had to handle redirects with WordPress, I have used a plug-in like Rewrite . 每当我不得不使用WordPress处理重定向时,我都会使用Rewrite之类的插件。 It gives you a nice interface to create rewrite rules. 它为您提供了一个不错的界面来创建重写规则。
I've found it's a lot easier than fiddling with the .htaccess
file directly. 我发现它比直接摆弄.htaccess
文件容易得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.