Site logo

Archived topic

Custom Taxonomy & Custom Post Type Template creation

6 replies · Started by Anastasia on July 19, 2022

Viewing posts 1–7 of 7

Greetigns everyone,
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 ?

Hello Fernando.
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 post

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.

Yes I did set has_archive to true .

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.

I see. Glad it's working now. You’re welcome Anastasia!

This archived topic is closed to new replies.