Is it possible for a custom post type to have a permalink as domain.com/custom-slug/
instead of domain.com/custom/custom-slug/
?
I can’t seem to achieve it. rewrite
argument while registering it either defaults to the latter one or a custom one by using 'rewrite' => array( 'slug' => 'blah-blah' )
Take a look at my answer to the following question. You can modify my
parse_request()
to get what you need:And you can read the following to see why what you want can cause issues in WordPress and requires a complex solution:
UPDATE
Based on the comment I decided to go ahead and implement this as the next revision of the plugin. It’s really only tested for the use-case for this question and the one from the prior referenced question. Over time I plan to implement it for all potential use-cases, as questions or clients occur to drive the demand.
Here is the code you’d place in your theme’s functions.php file to set it up for the post_type
'custom'
:And here is the plugin which you can place in
/wp-content/mu-plugins/
:To completely remove the slug so that the URL structure would look like:
in your register_post_type set
hope this helps
Although it hasn’t been updated for 2 years, the below plugin worked for me:
http://wordpress.org/plugins/remove-slug-from-custom-post-type/
FYI I’m running WP
3.9.1
with WP Types1.5.7