admin管理员组文章数量:1435859
I'm losing my mind, so I do hope I can get some help here..
What I'm trying to do is to create an optional parameter for search page, just for the sake of SEO
For example, there are the options:
/search/ (category = null)
/search/contracts (category = contracts)
/search/.../ (category = whatever this parameter $1 is)
While search is a page
I've tried adding htaccess rewrite rule, and wordpress simply redirected 301 without passing the parameter. Then I tried with add_rewrite_endpoint, nothing worked whatsoever and I've tried with
function wpd_add_query_vars( $qvars ) {
$qvars[] = 'category';
return $qvars;
}
add_filter( 'query_vars', 'wpd_add_query_vars' );
add_rewrite_rule(
'^search/([^/]+)/?',
'index.php?post_id=806&category=$matches[1]',
'top'
);
add_rewrite_tag('%category%', '([^&]+)');
flush_rewrite_rules();
Do note I tried just about every permutation, also tried plugins, nothing worked. It was either a 404 or the $wp_query->query_vars did not include the parameter.
Thanks in advance..
本文标签: permalinksCustom optional parameter in page URL
版权声明:本文标题:permalinks - Custom optional parameter in page URL 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745674355a2669760.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论