admin管理员组文章数量:1435228
I'm currently having a small issue with add_rewrite_rule
and can't seem to find any similar issues on stack overflow (even though there seems to be a lot).
It works fine for every URL I try:
profile/0/
profile/2/
profile/12313131/
I'm able to get the variable easy enough using $wp_query->query_vars['pid']
But if I try:
profile/1/
it always redirects to profile/
This is the only value that won't work. I can work around this if need be but wondering why this is the case? This is the first time I've had to use add_rewrite_rule
and I normally just use htaccess
.
Any help would be greatly appreciated.
The code I'm using is:
function profile_rewrite() {
add_rewrite_tag('%pid%', '([0-9]+)');
add_rewrite_rule('^profile/([0-9]+)/?', 'profile/?pid=$1', 'top');
}
add_action( 'init', 'profile_rewrite', 10, 0 );
本文标签: rewrite rulesaddrewriterule redirects if value1
版权声明:本文标题:rewrite rules - add_rewrite_rule redirects if value = 1 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745642386a2667935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论