admin管理员组文章数量:1384254
I have this definiton to add a query var:
add_filter( 'query_vars', 'add_reg_query_vars', 10, 1 );
function add_reg_query_vars($vars)
{
$vars[] = 'seminar'; //
return $vars;
}
and this definition to add a rewrite rule:
add_rewrite_rule(
'^seminare/([a-zA-Z0-9]+?)/([^/]*)/?$',
'index.php?pagename=seminare/$matches[1]&seminar=$matches[2]',
'top'
);
Like this it is working well, links like /seminare/mysite/123/ are matched, but because I have on same page 'seminare' a pagination, I need to exclude the word 'page', that a link like seminare/page/2 is
not matched by my regex above.
Can't get it to work, and honestly I'm not very experienced with the usage of regex. Tried several expressions and when I use for example:
^seminare/(?!page).+?/([^/]*)/?$
or
^seminare/(?!page)([a-zA-Z0-9]+?)/([^/]*)/?$
which matches in reg-tester it doesn't work in wordpress (tested with monkeyman rewrite analyzer). Links like seminare/page/2/ are not matched anymore, that's good, but a link like above like /seminare/mysite/123/ aren't matched anymore as well.
Would be all happy about some assist in that!!!!
I have this definiton to add a query var:
add_filter( 'query_vars', 'add_reg_query_vars', 10, 1 );
function add_reg_query_vars($vars)
{
$vars[] = 'seminar'; //
return $vars;
}
and this definition to add a rewrite rule:
add_rewrite_rule(
'^seminare/([a-zA-Z0-9]+?)/([^/]*)/?$',
'index.php?pagename=seminare/$matches[1]&seminar=$matches[2]',
'top'
);
Like this it is working well, links like /seminare/mysite/123/ are matched, but because I have on same page 'seminare' a pagination, I need to exclude the word 'page', that a link like seminare/page/2 is
not matched by my regex above.
Can't get it to work, and honestly I'm not very experienced with the usage of regex. Tried several expressions and when I use for example:
^seminare/(?!page).+?/([^/]*)/?$
or
^seminare/(?!page)([a-zA-Z0-9]+?)/([^/]*)/?$
which matches in reg-tester it doesn't work in wordpress (tested with monkeyman rewrite analyzer). Links like seminare/page/2/ are not matched anymore, that's good, but a link like above like /seminare/mysite/123/ aren't matched anymore as well.
Would be all happy about some assist in that!!!!
Share Improve this question asked May 11, 2020 at 13:45 Joe LippsJoe Lipps 91 bronze badge1 Answer
Reset to default 0It's not understandable for me, but the second definition works now. No idea, why it didn't work before, but I guess, somewhere I made a small mistake. Sorry, for my useless post ;)
本文标签: url rewritingNeed help with regex
版权声明:本文标题:url rewriting - Need help with regex 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744483060a2608283.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论