Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For a custom post type page I'd like to completely remove the slug so that the URL structure mirrors http://my-domain.com/CPT-title/ or http://my-domain.com/CPT-category/CPT-title . If I set the rewrite parameter to

'rewrite' => array('slug' => '', 'with_front' => false)

Wordpress freaks out and I get 404 on all pages except for the CPT page. If I don't define slug at all, then it defaults to the CPT name.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You have to set 'slug' to false and not a blank string.

share|improve this answer
I had tried the same code and had a problem, you're saying to set 'slug' to false so is this right or wrong 'rewrite' => array('slug'=>false,'with_front'=>false), this doesn't work for me the slug's still being generated. What should the code be? Thanks –  Anagio Dec 22 '12 at 19:12
Setting the slug to false (and refreshing permalinks) seems to create a redirect for me to the full URL WITH the CPT-name/page-name –  BenRacicot Jun 15 '14 at 21:48

Setting the slug paramter to false doesn't seem to work for me in WP 3.1. It still adds the slug of the custom post name.

By setting slug to '/', that seems to set the url correctly (without a slug). Like this: 'rewrite' => array('slug' => '/', 'with_front' => false). But then I get a 404 when trying to load it.

Is there a way to do this? It seems like you need a slug with custom post types.

share|improve this answer
This might help you, I am yet to try it - wordpress.stackexchange.com/questions/10804/… –  Ashfame Mar 31 '11 at 21:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.