Archived topic
content template
3 replies · Started by Hung on March 2, 2022
If I understand correctly, content template is a loop applying for the whole page. What should I do, if I want to build a page with 3 parts:
- a slider on the top
- a list of 3 other pages in the middle.
- a list of 5 latest posts with a specific tag on the bottom.
Can I do with GP Elements? Or will I need to create a page template in "traditional" way?
Thanks.
Hi there,
Content Templates don't output a loop.
If you check out the archive.php template as an example you will see the generate_do_template_part function inside the loop:
that function is inside the themes content templates; and the Block Element - Content Template is simply hijacking that function.
We are working on a GenerateBlocks Query Loop Block, once that is live we will be looking at ways you CAN replace the entire loop with that Block.
However, for what you describe this kinda depends - is that a Static page you want to construct or is it an archive template of sorts ?
Hi. In this case, I am working on a static page, which will be the homepage. However, would like to have the same setup for category / archive template also.
Thanks.
OK its going to require some custom development i am afraid.
Some options and pointers:
For the Static Home Page you could build this out in the Editor.
But you will need a slider plugin, for the posts list you could use a plugin like WP Show Posts or you can use the core Query Loop Block.
For the Archives, you can add stuff before and after the loop using Block Elements or Hook Elements - for example the Slider could be added as a Block Element - Page Hero, or if you need to progmatically add it use a Hook Element and the generate_after_header hook.
For the archive loop you could use the Content Template block element to style them.... but if you need to split the loop then you will need to build your own templates the traditional way.