Search code examples
phpwordpressurl-rewritingcustom-post-typeslug

WordPress slug without custom post type slug


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


Solution

  • I do not think there is straight forward solution this. If you need this so badly you can use Custom Rewrite For Post Slug