0

Rebuilding an author/writer website in WordPress.

I have a custom post type of books. Working OK.

I'd also like my category base to be books. Not working as yet.

So a book URL would be like:

https://www.authorname.com/books/title

And a category URL would be:

https://www.authorname.com/books/fiction

How can I achieve this?

My workaround is a category URL like this (working using Category Base = books/category):

https://www.authorname.com/books/category/fiction

Would prefer to add code in functions.php or .htaccess than use a plugin.

Thanks

1

No, it's not safe to use the /books/ URL for both a category base and custom post type base. WordPress uses the URLs to determine what type of content to serve. If you've set up 2 different types of content at the same URL, it won't have any way to know which you're requesting, and if you end up with a book slug that's the same as a category slug, you'll really have conflicts.

To keep the URL types segregated but still logical, you could use URLS such as

CPT: example.com/book/title-of-a-single-book

Category: example.com/books/category-name

Or, perhaps something like

CPT: example.com/books/title-of-a-single-book

Category: example.com/book-categories/category-name

Or, continue using your workaround, example.com/books/category/category-name, and they will all appear to be under "books."

  • OK. I'll continue to use my current workaround. Thanks – Matt Sephton Sep 30 at 15:43

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.