- This topic has 17 replies, 3 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
February 2, 2023 at 7:33 am #2518578
Mark
Hi,
I am a complete newbie at this but need some help with using an Element Block.
– I have used CPT UI to create a new Post Type (ie Products)
– I have used ACF to create different Product Categories (ie shirts, cap, etc)
– I have created a Block Element with dynamic Product details (image, title, etc)All the pages will use this same Block Element template section (and will just be filtered depending on category etc)
How do I use this Block Element in my Query Loop, so that this is the Block is repeating on each page and so the user doesn’t have to click on the link to go to this Block Template?
So effectively I just want to have the block template repeating based on parameters per page (for example like https://thepointsguy.com/credit-cards/best/ or like a directory site)
Hope this makes sense
February 2, 2023 at 8:34 am #2518757David
StaffCustomer SupportHi there,
1. Create a Block Element – Loop template.
2. Set the Display Rules > Location to yourProduct Archive.
3. Add the GB Query Loop block, in its settings DO NOT select and Parameters, just enable theInherit Query from TemplateThat will now output a query loop to that post types archive pages.
NOTE: this relies on the archive using the themes archive.php template.
February 2, 2023 at 8:56 am #2518785Mark
Hi David,
Thanks for the reply, maybe I haven’t understood you correctly
What I need is for the Block Element section to be looped based on the category on the same page.
I can do this with a Query Loop (using a my own Post Type)
Post Type -> MyProducts
Parameter – Taxonomies – MyCategories
Select Terms -> Category1, Catergory2 etcBut the issue I see with this is:
1. If I need to make a change to the Product Template, I need to do this on all the Pages (that is why I wanted to use a Block Element)
2. The Post Per Page is limited to 50 (which I am sure can be changed in the code?)Thanks again for the help
February 2, 2023 at 9:17 am #2518810David
StaffCustomer SupportYou want the Block Element – Loop Template.
If i register a CPT, that
has_archivesthen it will use the GParchive.phpwhen you view its archives eg.somedomain.com/product/category/some-category-termThe Block Element Loop template allows you to replace the loop in the
archive.phpwith its own content.
And if that content is a GB Query loop with no params and just theInherit Query from Templateenabled then it will display posts that match the current query.So you create 1 x Block Element loop template in that way and set the Elements Display Rule Location to All the relevant archives and it will do the rest.
February 3, 2023 at 7:41 am #2520113Mark
Hi David,
Sorry for not getting this.
– In CPT UI I have enabled the Archive for this CPT (“Products”)
– I have created a Block Element (“Product Block Template”)
– Updated the Element Type to Loop Template
– In the Display Rules selected “Product Archive”Now on a New Page
– Added a container and then added a Query LoopThis is where I get stuck?
– If I chose a layout here gives me all the CPT (“Products”) but this means that I have to redesign a layout here and then the users have to click here to go to the Block Element (“Product Block Template”)?
– Just want the Block Element (“Product Block Template”) to be shown here, repeated for all the CPT (“Products”)So can you help with explain how I
1. Get the Block Element (“Product Block Template”) to show on this page for all the CPT (“Products”)
2. Then be able to filter it based on CPT Taxonomies I have created (“Category 1”, “Category 2” etc) for this pageSorry if I am missing something obvious!
February 3, 2023 at 8:08 am #2520249David
StaffCustomer SupportFirst thing is to build your template:
1. in Appearance > Elements -> Add New –> Block Element.
2. in the element settings set the Element Type to:Loop Template.
3. in the element editor Add the Query Loop Block.
3.2 do not set any parameters on the Query Loop block just enableInherit Query from Template
4. set the Element Display Rules to the Product Archive.Now if you go to your Product Categories and view one of them, you should see the Block Element Loop template.
Does that work ?
Once thats done we can look at options to add those category buttons.
February 3, 2023 at 9:04 am #2520328Mark
Thanks for trying again, I followed the steps you suggested and still can’t get this to work!
So just so I understand – I need to build the Block Template within a Query Loop?
Think I am to reset the website and start over as maybe have missed something in my setup.
February 3, 2023 at 11:03 am #2520472Ying
StaffCustomer SupportSo just so I understand – I need to build the Block Template within a Query Loop?
You need to build a loop template by adding a query loop block into a
block element - loop template.
https://docs.generatepress.com/article/block-element-loop-template/February 4, 2023 at 2:13 am #2520935Mark
Thanks for your help, think I have worked it out!
February 4, 2023 at 3:55 pm #2521589Ying
StaffCustomer SupportGlad to hear that 🙂
February 6, 2023 at 3:04 am #2522982Mark
Hi Guys,
Sorry to open this up again, but I have tried all the above options and still can’t get this to work they way I envision it.
Just to recap:
– I would like to create a block element (Loop Template?) that has all the ” Product Details”
– I would then like to be able to reuse this block throughout my website on mutiple pages, which will be filtered by taxonomy
– i.e. From 50 Product Blocks, on the page ” Shirts” will only show “Shirts”
– I would like to see each block as a sections below each other on the page (not a seperate template that needs to be clicked to, which I see when I tried using the archive option).
– Effectively I am trying to build a very simple directory layout, using this repeating block element, one on top of each other, all the way down the page and where I can use the CPT that I have created to then filter each page by taxonomy or categoryI have tried everything advised in this thread but still can’t seem to get it to work?
I can’t seem to pull the Block Element Loop Template on a page to use it there?Thanks again for your help
February 6, 2023 at 5:29 am #2523109David
StaffCustomer SupportDoes your site have any published posts on it yet ?
If it does, can i see the site ? And perhaps an admin login so i can see whats going on.February 6, 2023 at 6:17 am #2523149Mark
Just what is on the Wired Template
Will add the details in the Private Info
February 6, 2023 at 7:54 am #2523352David
StaffCustomer SupportCan you share the URL ?
February 6, 2023 at 8:09 am #2523368Mark
Sure
-
AuthorPosts
- You must be logged in to reply to this topic.