- This topic has 6 replies, 3 voices, and was last updated 3 years, 8 months ago by Tom.
-
AuthorPosts
-
July 17, 2020 at 7:55 pm #1367299Henry
I am trying to create a template for Custom Taxonomy, using the archive page template.
To do this, typically (as I understand it) you simply copy/paste the archive.php page and rename it taxomony-{slug}.php with the “slug” being the name of the Custom Taxonomy.
All nice and simple and that works.
I have a child theme setup and I placed the taxomony-{slug}.php in there and it worked just fine.
However, I notice that in GeneratePress there is this code:
/* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() );
So, what I thought would work would be me copy/pasting the content.php file, modifying it, then placing the renamed content-my-slug.php like this:
/* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content-my-slug.php', get_post_format() );
^ I placed this in the child theme and it didn’t work.
So! My question is, what is the correct way of finding the ‘content-my-slug.php’ in my child theme? Do I need to add more code? WordPress can’t seem to find it.
Thanks!
July 17, 2020 at 7:58 pm #1367300HenryI guess the answer lies in here:
(where ___ is the Post Format name) and that will be used instead
What is this? Is the “Post Format Name” the same as the taxonomy slug?
July 18, 2020 at 6:25 am #1367613DavidStaffCustomer SupportHi there,
do you need to change the taxonomy content ?
If it works how you want it then there is no need to create a separate content template.
Let me knowJuly 18, 2020 at 6:55 pm #1368207HenryThanks, David, in fact, I need to remove the archive loop from that particular Custom Taxonomy archive page.
I’m thinking it would be best to do that with the template option here:
/* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content-my-slug.php', get_post_format() );
The issue I have is understanding how to link to the file “content-my-slug.php”
Hope that makes sense and my approach does too
Thanks
July 19, 2020 at 9:43 am #1368833TomLead DeveloperLead DeveloperHi there,
Try this instead:
get_template_part( 'content', 'my-slug' );
This assumes there’s a file named:
content-my-slug.php
Let me know ๐
July 22, 2020 at 1:42 am #1371810Henryworked great thanks
July 22, 2020 at 9:14 am #1372399TomLead DeveloperLead DeveloperYou’re welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.