2

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.

1 Answer 1

2

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

2
  • 1
    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, 2012 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 Jun 15, 2014 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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