Site logo

Archived topic

Use a reuseable block within a GPblocks query loop.

5 replies · Started by Justin on November 21, 2022

Viewing posts 1–6 of 6

In summary, I’m trying to use a reuseable block within a GPblocks query loop.

To start, I created a GPBlocks query loop and then set its taxonomy to a posts category. I then made the grid within that query loop a reusable container. My goal is to create a blank GP query loop on future pages that has a different posts catagory, but then add the reuseable block grid to control styles globally across my site (if needed in the future). In other words, the query loop controls what posts appear in the grid, and the “child” reuseable block controls the styles that appear in the grid.

It actually works in the WP editor, but not in my staging site. Subsequent pages where I add the reuseable block show posts from the first page where I created the reuseable component.

Here’s the page where I made the reuseable block (staging user/pw: dev/dev)

Here’s a page where I tested adding it to a new, blank query loop. (staging user/pw: dev/dev). There should only be one article that appears in this query loop (and it behaves properly in the editor), but it shows post assigned to a different category when I publish and check on my staging site.

Thanks in advance for any insight you can provide.

Hi Justin,

Try placing everything under the Post Template Block inside a Container Block, and then make this Container Block the one that's reusable.

Example: https://share.getcloudapp.com/nOu1gdRQ

Thanks for the quick reply! (We're so impressed with your support)

I got this to work after clicking around enough, but by doing this, you lose all the layout and spacing settings for the Post Template block. You also lose the layout settings for the Grid block.

Was that your experience as well? Perhaps I'm missing something?

Yes, that's natural. We just made the content of the Post Template Block the one that's Reusable.

You're not missing anything. Making the Grid Block or Post Template Block the reusable Blocks, causes issues for the Query Loop Block. As this is a WordPress Block, how it functions would be out of our scope.

We usually advise our customers to use the Local Pattern feature of GenerateBlocks Pro. Reference: https://docs.generateblocks.com/article/pattern-library-overview/

However, Local Patterns already added do not update automatically as would a Reusable Block. It's meant to work just as a "Pattern".

That makes sense. Thanks again for the quick replies.

You're welcome, Justin!

This archived topic is closed to new replies.