admin管理员组文章数量:1327966
For a specific post, I want to create the illusion of child-posts.
The current post permalink structure is set to /%year%/%postname%/
. So using this post URL as an example:
/2020/post-slug/
I would also like the following URLs to render the same Post:
/2020/post-slug/hello/
/2020/post-slug/small-world/
My hope was that something like this would suffice (in functions.php), where the Post ID
is 1000
:
function custom_rewrite_rule() {
add_rewrite_rule('^2020/post-slug/([^/]*)/?','index.php?p=1000&path=$matches[1]','top');
}
add_action('init', 'custom_rewrite_rule', 10, 0);
The idea is that I would also pass the additional path information to the post which would be picked up in the template for some changes to original post.
When I do this, it loads the intended post but the URL changes back to:
/2020/post-slug/
...and I wanted the longer one to remain.
(I hard-flush rewrite rules in-between attempts).
本文标签: url rewritingAllowing multiple URLs for same Post
版权声明:本文标题:url rewriting - Allowing multiple URLs for same Post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742223773a2435637.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论