[Support request] Which template controls the post preview that is shown in the archive template?

Home Forums Support [Support request] Which template controls the post preview that is shown in the archive template?

Home Forums Support Which template controls the post preview that is shown in the archive template?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2363389
    Wesley

    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.php which is copied from GP’s archive.php file.

    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?)

    archive.php calls 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…)

    #2363625
    Fernando
    Customer Support

    Hi Wesley,

    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.php template. 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' );

    or

    generate_do_template_part( 'your-cpt-content-slug' );

    for example

    #2364347
    Wesley

    Hi Fernando,

    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.php in 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( 'services' )?

    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…?

    #2364808
    Fernando
    Customer Support

    1. It uses content.php unless 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' );
    https://docs.generatepress.com/article/setting-up-a-simple-custom-post-type/

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.