Site logo

[Resolved] Element – Query

Home Forums Support [Resolved] Element – Query

Home Forums Support Element – Query

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #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

    #2518757
    David
    Staff
    Customer Support

    Hi there,

    1. Create a Block Element – Loop template.
    2. Set the Display Rules > Location to your Product Archive .
    3. Add the GB Query Loop block, in its settings DO NOT select and Parameters, just enable the Inherit Query from Template

    That will now output a query loop to that post types archive pages.

    NOTE: this relies on the archive using the themes archive.php template.

    #2518785
    Mark

    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 etc

    But 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

    #2518810
    David
    Staff
    Customer Support

    You want the Block Element – Loop Template.

    If i register a CPT, that has_archives then it will use the GP archive.php when you view its archives eg.

    somedomain.com/product/category/some-category-term

    The Block Element Loop template allows you to replace the loop in the archive.php with its own content.
    And if that content is a GB Query loop with no params and just the Inherit Query from Template enabled 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.

    #2520113
    Mark

    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 Loop

    This 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 page

    Sorry if I am missing something obvious!

    #2520249
    David
    Staff
    Customer Support

    First 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 enable Inherit 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.

    #2520328
    Mark

    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.

    #2520472
    Ying
    Staff
    Customer Support

    So 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/

    #2520935
    Mark

    Thanks for your help, think I have worked it out!

    #2521589
    Ying
    Staff
    Customer Support

    Glad to hear that 🙂

    #2522982
    Mark

    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 category

    I 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

    #2523109
    David
    Staff
    Customer Support

    Does 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.

    #2523149
    Mark

    Just what is on the Wired Template

    Will add the details in the Private Info

    #2523352
    David
    Staff
    Customer Support

    Can you share the URL ?

    #2523368
    Mark

    Sure

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