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.

2

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

  • 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 '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 – Ben Racicot Jun 15 '14 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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