admin管理员组文章数量:1130349
I'm lost in the world of Wordpress rewrites and I'm hoping someone can help...
I'm creating two custom members areas from my site; users logged in as certain roles will be able to view certain posts, guests won't be able to see the posts.
There are two areas for members, let's call them gold and silver
The gold/silver members 'dashboards' will be at or
I want to create a rewrite rule for blog posts so that if you go to you see the post with a name of post-slug-here (without redirecting to ). I need to keep the URL so I know which area the user is in (some posts will be viewable in both)
I've tried...
add_action( 'init', 'members_area_single_rewrites' );
function members_area_single_rewrites() {
add_rewrite_rule(
// The regex to match the incoming URL
'gold/(.+?)/?$',
// The resulting internal URL
'index.php?pagename=$matches[1]',
// Add the rule to the top of the rewrite list
'top' );
}
I am resaving in Settings -> Permalinks after every code change.
Now if I visit the URL, it finds the post, but redirects to the non-prefixed URL. What am I missing?
I am also not sure if I can add 'gold' or 'silver' as an area query_var so that I can then do something like if (get_query_var('area') == 'gold') which would be super helpful.
I'm lost in the world of Wordpress rewrites and I'm hoping someone can help...
I'm creating two custom members areas from my site; users logged in as certain roles will be able to view certain posts, guests won't be able to see the posts.
There are two areas for members, let's call them gold and silver
The gold/silver members 'dashboards' will be at or
I want to create a rewrite rule for blog posts so that if you go to you see the post with a name of post-slug-here (without redirecting to ). I need to keep the URL so I know which area the user is in (some posts will be viewable in both)
I've tried...
add_action( 'init', 'members_area_single_rewrites' );
function members_area_single_rewrites() {
add_rewrite_rule(
// The regex to match the incoming URL
'gold/(.+?)/?$',
// The resulting internal URL
'index.php?pagename=$matches[1]',
// Add the rule to the top of the rewrite list
'top' );
}
I am resaving in Settings -> Permalinks after every code change.
Now if I visit the URL, it finds the post, but redirects to the non-prefixed URL. What am I missing?
I am also not sure if I can add 'gold' or 'silver' as an area query_var so that I can then do something like if (get_query_var('area') == 'gold') which would be super helpful.
本文标签: url rewritingPrefix only some posts with a custom prefix
版权声明:本文标题:url rewriting - Prefix only some posts with a custom prefix 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749151212a2323850.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论