I have created a custom post type 'books', but I don't want to use archive-books.php to list the books. I need to use a static page to list my books because I would like to add content using the content editor.

I would like this structure:
www.example.com/books ----> It is a static page
www.example.com/books/book-title ---> it is single post type

The problem is that I get a 404 when I try to go into my single post.

Can you help me?

  • I'm assuming your post type has a URL rewrite (when registering it) as 'books' ?
    – Howdy_McGee
    Oct 3 '14 at 16:18
  • 1
    Yes, the url rewrite is 'books' Oct 3 '14 at 17:16

Set has_archive to false. In order to keep the URL structure you want (/books/book-name), you'll need to add a rewrite rule:

'rewrite' => array('slug' => 'books'),
  • Perfect!! That was the problem. Thank you very much :) Oct 3 '14 at 18:08

If you're still experiencing troubles after using Johannes' solution:

Try to update your permalink structure in the WordPress backend! Most often you just have to re-save the settings. If this doesn't help, change the permalink structure and save it. Then undo the changes and save your original structure. This process will force WordPress to update all URLs!

  • Just visiting the permalinks settings page flushes rewrite rules, no need to save or change anything.
    – Milo
    Jan 7 '17 at 16:58

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.