I have register custom post type with following code:
register_post_type(
array(
'labels' => // array of labels,
'public' => true,
'publicly_queryable'=> true,
'show_ui' => false,
'map_meta_cap' => true,
'show_in_menu' => false,
'query_var' => true,
'rewrite' => array( 'slug' => 'movie' ),
'capability_type' => 'post',
'has_archive' => false,
'exclude_from_search' => true,
'supports' => array('title'),
)
);
The issue is that, the URL become for this post like:
http://yourdomain.com/movie/post_slug/
But, I need like:
http://yourdomain.com/post_slug/
Is there any way to remove post type slug "movie" from URL, like posts and pages display at front-end by default?
Thanks
You must register your post type movie in init.
To replace the movie from post link use the below code.
After that you can set your post type shold be like a default post or page.
Have you tried:
https://codex.wordpress.org/Function_Reference/register_post_type
I do not think there is straight forward solution this. If you need this so badly you can use Custom Rewrite For Post Slug
It's simple: set
'rewrite'-> true
in yourargs array
.