最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

url rewriting - Post & Page with same slug

programmeradmin1浏览0评论

I've got a post and a page with this slug: signatures-for-office-365 That's right, the same slug for a post and page.

Permalinks settings are: /news/%postname%/

When the post URL is requested, wp takes them to the page instead, like so:

Requested:/news/signatures-for-office-365

Result:/signatures-for-office-365

I've tried this:

add_action('init', function () {
 add_rewrite_rule('news/signatures-for-office-365/?$','index.php?name=signatures-for-office-365', 'top');
}, 1000);

I've tried this:

add_action('init', function () {
 add_rewrite_rule('news/signatures-for-office-365/?$','index.php?post_type=post&postid=17508', 'top');
}, 1000);

Both of which gives the URL I want, but the page displays the blog home instead. Outside of changing the slug to the post, any solutions? Thank you in advance.

I've got a post and a page with this slug: signatures-for-office-365 That's right, the same slug for a post and page.

Permalinks settings are: /news/%postname%/

When the post URL is requested, wp takes them to the page instead, like so:

Requested:/news/signatures-for-office-365

Result:/signatures-for-office-365

I've tried this:

add_action('init', function () {
 add_rewrite_rule('news/signatures-for-office-365/?$','index.php?name=signatures-for-office-365', 'top');
}, 1000);

I've tried this:

add_action('init', function () {
 add_rewrite_rule('news/signatures-for-office-365/?$','index.php?post_type=post&postid=17508', 'top');
}, 1000);

Both of which gives the URL I want, but the page displays the blog home instead. Outside of changing the slug to the post, any solutions? Thank you in advance.

Share Improve this question asked Jun 1, 2017 at 18:18 rpasillasrpasillas 1 2
  • I can't reproduce that behavior with a new install and default theme, verify that it's not a plugin or your theme causing this. – Milo Commented Jun 1, 2017 at 18:50
  • You might be onto something because this wasn't a problem for me with a local dev copy of the site. I'll see if I can check it out. – rpasillas Commented Jun 1, 2017 at 20:35
Add a comment  | 

1 Answer 1

Reset to default 0

A simple way to fix this is to edit either the post or page, then change the permalink on the post/page to something unique.

发布评论

评论列表(0)

  1. 暂无评论