1

I have multiple custom post types and all of them have to have their own "homepage". The url of this homepage is very important and must be the same with part of the url of the individual posts. For example:

example.com/custom-post-type/ <- the homepage for this custom post type 
example.com/custom-post-type/title-for-a-post/ <- show the page for a post in that custom post.

The issue is that I am getting url conflicts and wp does not run the right templates. I cannot have an empty url for custom-post-type/ so I tried creating a different custom post type and removed the slug. But this is also causing it to render the wrong templates.

Any idea how to approach it? Each custom post type has radically different templates and fields.

Thanks!

1

This is exactly how wordpress works.

For each Custom Post type Create an archive-custom_post_type_name.php and a single-custom_post_type_name.php

Wordpress automatically loads that file when someone goes to the url.

so if your custom posts types were koolio and notsokool then you would need these 4 files in your theme child (you're using a child theme, right?!)

archive-koolio.php single-koolio.php archive-notsokool.php single-koolio.php

I would take the single file out of your theme folder and copy it to your child them, then add the CPT extension. Do the same for the archive template.

rememeber you'll have to flush the re-write rules if your plugin isn't set to do this by itself...just go to seetings/permalinks and hit save.

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.