How to Add Pages Under Custom Post Type URL Structure?

I really should just try to think things out thoroughly before instantly asking questions.

I found a very easy solution. It’s not exactly adding “pages” but it does what I need.

When registering the custom post type, there are two things which need to be specified.

By default, the parameter hierarchical is set to false. Solution: set hierarchical => true;

In order for the hierarchical functionality to work, you need to add page-attributes to the supports parameter.

Now, just create a new post in your custom post type called “archives” and select no parent.

Then create another new post, “daily” (for example), and select “archives” as the post parent.

Easy enough.

However, if you have a “page” with a slug of “archives”, it seems that your knowledge base “archives” will have a slug of “archives-2” instead of just “archives”.

If you encounter that problem, then update to WordPress 4.1. It allows duplicate slugs across multiple post types.

Leave a Comment