I created a new post type in the WordPress functions.php
file and the default slug is www.website.com/blog/new-slug, but I want it to be www.website.com/new-slug only. How do I remove /blog/ from the slug? I have 'hierarchical' => true,
to so the post type acts like pages and also 'rewrite' => array( 'slug' => 'new-slug' ),
, but it is not working, and /blog/ is in the slug for the new post type. Any insight would be helpful.
I figure it out. No idea why I missed this.
The rewrite
parameter of the register_post_type()
function has a parameter of with_front
that when set to false will not be prepended with the front base specified by the permalink structure.
register_post_type( 'cpt', array(
'rewrite' => array(
'with_front' => false,
)
);
The above will prevent /blog/
from being on URLs for your CPT's posts.