Post & Page with same slug

Question

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.

0
, rpasillas 8 months 0 Answers 81 views 0

Leave an answer