- This topic has 6 replies, 2 voices, and was last updated 2 weeks, 5 days ago by Fernando.
July 19, 2022 at 12:23 am #2286980Anastasia
I’ve made a custom post type and taxonomy which I’ve already registered inside my child theme’s functions.php.
I’d like to know if there is a guidline or a detailed documentation (something I searched for already but didn’t find anything in detail so far) for creating my own templates for taxonomy archive template and single custom post type custom template.
Which files I need to use and overide them inside my child theme folder?
Do I need to create a folder “Templates” and include in there the templates ?July 19, 2022 at 12:41 am #2287000Fernando Customer Support
Here’s an article you may refer to regarding this: https://docs.generatepress.com/article/setting-up-a-simple-custom-post-type/
Hope this helps!July 19, 2022 at 12:46 am #2287004Anastasia
This was the post I was reading but unfortunately it’s not working. I think that I miss something.
Steps I did:
1) I copied archive.php into my child theme folder and renamed it as archive-products.php
2) I copied content.php into my child theme folder and renamed it as content-products.php
3) Inside archive-products.php in line 47 I changed
generate_do_template_part( 'archive' );
into get_template_part( 'content', 'products' );
Alhough when I try to comment out some lines inside content-products.php to check if anything changes in the content I’m seeing on the frontend nothing changes.
I’m trying to create two new layouts (templates) for my custom taxonomy category archive and custom taxonomy single postJuly 19, 2022 at 1:01 am #2287015Anastasia
I’ve just followed the guide you sent me for the single and content single and it works as far as I can see.
My problem though for archive.php for my custom taxonomy still exists. I’ve made a php file named taxonomy-product_category.php and I copied everything from archive.php inside of it. If I commend the loop I get no results in the archive page of my custom taxonomy. That tells me that the file works properly. Though I can find which is the constructor of the html template which echos inside the loop.July 19, 2022 at 1:56 am #2287060Fernando Customer Support
To clarify, when you created your CPT, did you set
To be sure, can you try using a plugin like this: https://wordpress.org/plugins/show-current-template/ and check if the template used in your CPT archive is the template you added.
Kindly let us know.July 19, 2022 at 2:09 am #2287066Anastasia
Yes I did set
For now I created a file named taxonomy-product_category.php and I’ll start coding from blank in order to create the layout I need. I kept only the hooks for header and footer. Seems it’s working.July 19, 2022 at 10:32 pm #2288048Fernando Customer Support
I see. Glad it’s working now. You’re welcome Anastasia!
- You must be logged in to reply to this topic.