Even though this question sounds like others here is my problem:
The site I am updating had a permalink structure of /%postname%, during this time I created a custom post type of “popups” (rewrite slug = ‘popups’) so the urls were:
/popups/the-post-name
Now the site has a blog, and the permalink structure has been changed to /blog/%postname%, this changed the custom post type url structure to:
/blog/popups/the-post-name
I want to keep the blog permalink structure as /blog/%postname% but I want to have a custom url structure for my custom post type that is not tied to the blog permalink. So instead of the urls for my custom post type of popups showing up as:
/blog/popups/the-post-name
I want it to show up as:
/popups/the-post-name
while retaining the blog permalink of /blog/%postname%
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
When you registered the post type, one of the arguments was rewrite, which took an array. make sure there’s a with_front argument in the rewrite array, and set it to false.
<?php
$args = array(
// other stuf...
'rewrite' => array(
'slug' => 'popups',
'with_front' => false
),
// other stuf...
);
register_post_type( 'type', $args );
That should take care of it.
Important: Be sure to flush your rewrite rules after changing the code (go to settings > permalinks and hit save).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0