Archived topic
Question on taxonomy-custom.php and the GP "content" path
6 replies · Started by Henry on July 17, 2020
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!
I 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?
Hi 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 know
Thanks, 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
Hi there,
Try this instead:
get_template_part( 'content', 'my-slug' );
This assumes there's a file named: content-my-slug.php
Let me know :)
worked great thanks
You're welcome :)