Archived topic
Query loop arguments - reusable block
11 replies · Started by Henrik on September 14, 2022
Hi,
first of all congrats to your superb system. I really enjoy using GB and GP. Unfortunately actually I'm facing a problem:
- I have Custom Post Type with title, image and text as well as ACF fields.
- In static articles I would like to show teasers (title, image, excerpt, acf field information) of some of the CPT posts.
- I created a reusable block with a query loop but in the query for the CPT (also normal posts) I can only select a "search" argument
- How can I query other fields like ID, acf values, taxonomies, terms??
- As a workaround I used the search argument to only select one post and added a second reusable block on the same page but unfortunately this doesn't work either, because both blocks are processing the same query and showing the same result. Changing the search query in one block does directly change the query in the other block.
- How can I achieve to show 3 specific CPT posts with a reusable block ? Is query loop the right way? I also tried dynamic data but this has led to set the search query in the article for each item like (title, image...). That doesn't make sense for me.
I would be very pleased about a hint for a solution!!
Hi Henrik,
Where are you adding the Query Loop Block in the articles? Are you trying to display the same 3 specific CPT posts in the articles you have in the same position? Have you tried using a Block Element instead of using a Reusable Block?
As for Querying custom field, you can use a Headline Block for instance to query post meta data such as ACF custom Text fields. The same goes for images. You can use a GB Image Block.
Hi Fernando,
Thanks for your fast reply.
I have the general Query Loop Block in the Reusable Block and am using this block in an article. There I try to set the specfic search: e.g. Article abour red shoes -> Insert Block and search for CPT posts with term red shoes and display the first 3 posts.
No, I didn't try a Block Element because I will add this block in several pages and it always has to look the same. So in this setup I will have to change it in 100 places when changing layout.
Yes, I found that query for custom fields but in that case as mentioned in my question I will always have to set the query for each item as title, image, etc. there is no option for a global query for that block. Or am I missing something?
Hi there,
You would need your Query to be created using the Current Post data, which is a GB Pro feature - see here:
https://generateblocks.com/creating-related-posts-with-query-loop-block/
Hi David,
sorry, I forgot to mention. I work with GP Premium 2.1.2 and GB Pro 1.3.0.
I would love to achieve the solution shown in the post but can't make it.
The only options shown when clicking on "Add Parameter" are:
- Select query parameter
-- Page
-- Offset
-- Search
Author, Order by, Taxonomies is not showing up. What am I doing wrong?
Hi Henrik,
Can you share temporary admin credentials? We'll check from our end what's occurring? May you also provide the link where you're adding the Query Loop.
Please use the Private Information field for this: https://docs.generatepress.com/?s=private+information
Sure.
You're currently editing the page you link, so we can't view it. Let us know once you're finished, and we'll check again.
Sorry for that. Just had the tab open. Closed it now.
I see.
I tried adding a Parameter to your Query Loop, and I can see the other stuff. Can you try clearing your browser's cache or try using a different browser?
Hi Fernando,
Thank you so much for your increadible support. The browser cache did the trick.
Very glad to be able to use this fantastic feature now!
You're welcome Henrik! Glad it's working now!