Home › Forums › Support › Which template controls the post preview that is shown in the archive template?
- This topic has 3 replies, 2 voices, and was last updated 5 months, 3 weeks ago by Fernando.
October 4, 2022 at 4:55 pm #2363389Wesley
I am working in a child theme and have created a custom taxonomy called “Services” which I am using to classify posts.
I have created a template file
taxonomy-services.phpwhich is copied from GP’s
My question is what template file controls the individual post previews which show up in the loop section of the archive template? (The file that contains the
<article>…</article>markup, the post title and featured image?)
generate_do_template_part( 'archive' );inside the post loop — what file does this refer to? (It looks like it would be archive.php… but it obviously cannot be, because it is being called from archive.php!)
(There is an article in the documentation (https://docs.generatepress.com/article/block-element-loop-template/) which says to create a Block-type Element and select “Loop Template” in the Element Type dropdown — but when I try that there is no “Loop Template” option in the dropdown…)October 4, 2022 at 11:35 pm #2363625Fernando Customer Support
The content template which displays the actual posts in the loop, is displayed using this function:
generate_do_template_part( 'archive' );
This calls the relevant
content.phptemplate. You can add your own custom templates in a child theme
Then, you can replace
generate_do_template_part( 'archive' );with:
get_template_part( 'content', 'your-cpt-content-slug' );
generate_do_template_part( 'your-cpt-content-slug' );
for exampleOctober 5, 2022 at 9:42 am #2364347Wesley
Thanks for the response. I have a couple follow-up questions:
1. Can you clarify for me how
generate_do_template_part( 'archive' )picks a template? Your answer implies that it would select a template named content-archive.php, but there is no such template in the GeneratePress theme (just content.php, content-link.php, content-page.php and content-single.php).
2. If I wanted to replace with a modified or custom template named (for example)
content-services.phpin my child theme, would I change generate_do_template_part(
'archive') to generate_do_template_part(
'content-services'), or would I simply change it to generate_do_template_part(
3. And lastly, can you address the missing “Loop Template” option in the Element type dropdown when creating a Block Element? Is the documentation article I linked above outdated (it says it was updated just a week ago), or is there a bug, or…?October 5, 2022 at 11:03 pm #2364808Fernando Customer Support
1. It uses
content.phpunless you have a specific template. The logic for this can be found here: https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/theme-functions.php#:~:text=if%20(%20%27archive,%7D
2. You can replace it with
get_template_part( 'content', 'services' );–
3. This is just in Beta. You’ll need to get the beta files of GP and GP Premium in https://generatepress.com/account/ if you want that feature to appear.
- You must be logged in to reply to this topic.