There have been a few recent posts about V1.5 beta and ACF repeaters working but I am still struggling with my use case.
I have a loop of Custom Post Types and within each I want to loop over Custom Taxonomies attached to them. For example, each staff member has multiple skills. I want to loop over the skills and style them.
I tried looping the taxonomy within each record since V1.3.7 but it just displays all terms. It seems to be no different in V1.5 beta.
Should it work? If not, do I need to create a custom shortcode to do it?
Within a custom post type I’m trying to query loop over the taxonomies, but it’s showing all taxonomies, not just the associated taxonomies to the post.
The expected result is that only some of the images (custom fields in custom taxonomy) would appear for each entry item. Right now all images are appearing for all entries.
You loop over all posts. Then within each found post, you loop again over all posts within category Platforms.
What dynamic key have you defined in the “Image” under Platforms?
I don’t think you actually need 2 loops.
You can define the key directly in the first (and only) loop. See my screen shot for reference.
I have a loop over the post type “rezepte” (screen shot 1). And within that query I added a text field called “Text post category” in which I defined the dynamic data key to be “{post_terms_category}” (screen shot 2). Note: I don’t have an image in my categories, that’s why I use a text field.
As a result, all posts within post type “rezepte” are shown and all the included category/categories per post are shown.
Ok, a complicated case. Maybe I understand it now.
I think the problem is that your second query loop is not connected to your first query loop, meaning no found data of the 1st query loop is used as a query loop parameter for the 2nd query loop.
Your first query loop finds all posts that have the post type GTM Templates. Your 2nd query just finds all items that are in the taxonomy Platforms.
I have a case, where I use a 2nd query loop to filter the posts that have the same category as the posts found in the 1st query loop.
I did this by using the taxonomy found in the 1st query loop as a parameter in the 2nd query loop. This was achieved by using the {post_terms_category} parameter (see the screen shot for reference).
Here you find all the available post parameters like that:
Under taxonomy, they list the following dynamic tags of the taxonomy terms assigned to a post:
I encountered the same problem. And I found a solution for it. But I solved it with a little bit of PHP code.
My scenario:
For my portfolio website I create a custom Post Type called Projects and in this post type, I’m showing different technologies used to develop that particular project.
In bricks builder, I used Query Loop to show All Projects. But I encountered problem when I tried to show each technology in a different span tag to style. Becuase, I didn’t find out solution for nested query.
Then, I used a PHP to show the technologies within the query Loop.
I’m also sharing a screenshot and PHP code. I used span tag you can use img tag to solved your problem.
<?php $technologies = get_field('technologies'); // get the list of technologies from ACF
if( $technologies ) {
foreach( $technologies as $technology ) {
echo '' . $technology . ' '; // wrap each technology in a span tag
}
}
?>
I’ve been trying to find a way to do that for ages now. It seems surprisingly hard to find good tutorials on that. I’ve been searching for ‘nested’ and ‘grouped’ lists/query loops - which is what found me this post here.
It would be great if the Bricks team (hi chaps) could add a few more examples about this direct to the academy pages (or anywhere) although now I’ve seen that BricksLabs example (which is exactly my use case, I was trying to create a ‘simple’ Product List (of Woo products) grouped (or nested by) product categories, which now seems a lot easier to understand (with hindsight).
And btw Bricks team… brilliant job on this option/logic - now that I’ve unlocked how to build them/ It’s a stunning achievement.
How do we exacty the opposite, where we want to pull in an image from an acf field in the taxonomy for a post? I can’t get it to happen. We have a product (CPT), which has a brand taxonomy (ACF Taxonomy), which has several field groups, one of which being the “brand_image_svg”. For the life of me, I cannot get that image to show, nor any other of that post’s “Brand” taxonomy fields. I have tried to use sub loops, but nothing I do to restrict to the one “Brand” assigned to the product works. I can get it to display fields from the entire Brand taxonomy in a loop, but specifying it to just the one specific “Brand” taxonomy term on the “Product” post has proven impossible.
UPDATE: SOLVED
I finally got it! For anyone in the same boat, the nested loop for getting terms fields under a post is like this:
Imagine you want to pull in the “Brand” logo from the “Brand” taxonomy assigned to a “Car” CPT.
Outer loop - Posts (I chose a CPT of mine called “Cars” in my example below)
Inner loop inside the post loop - Terms (I chose a custom ACF taxonomy i created called “Brands” in my example below)
Set “number” of terms to return to 1 returned (in my case, only one “Brand” to each “Car”).
The meta filter needs to have something in common between the term and the post, OTHER THAN the term_name. For my example, I added an ACF field for the “Cars” CPT store the “Brand Name” as a text field “cpt_car_brand_name”, and I added the same field to the Taxonomy as an ACF test field and called it “tax_brand_brand_name” that was set to a value identical to the “Brand” taxonomy term_name associated with car as its Brand taxonomy. Eg. If the Brand term name was “Audi”, I stored the “Audi” in the “Car” CPT ACF field “car_brand_name”. Then, in “Meta Query” of the Taxonomy query, set “Meta Key” to “tax_brand_brand_name” and Meta Value to “{acf_cpt_car_brand_name}”
Ahhhhh. Success.
I truly hope this saves someone hours and hours in the future
I have used a similar solution, using Happy Files Folders selected through a Select Advanced field (Metabox) and it only requires one query loop via the taxonomy query for the custom field with the value of the folder. It works great, but perhaps there is merit to having the option to tick a box for a taxonomy right there in the post…rather than relying on a separate step of grouping in folders?
One thing I have run into is where the option to select taxonomy exists in the post AND exists as an option through the field, the two conflict. That may have been due to a required field setting, I don’t recall.
Did you encounter any conflicts? IF so, how did you get around that issue? Did you hide the taxonomy in the sidebar and ONLY allow it in the field set…or some other solution?
Thanks for any response to this older, but informative and helpful thread.
I was able to implement the original scenario without custom PHP code so I’m leaving this for anyone looking for solution using the current version of Bricks (1.11.1.1).
The “CPT loop” element has a basic setup like this. Of course you should select your own CPT in place of my “Portfolio”. Of course you can loop standard Posts as well.
The “CTax loop” element has a Terms qurry. Of course you should select your own CTax in place of my “Użycia tekstu (Portfolio)”. Of course you can loop standard Post Tags as well. The most important setting is in the bottom left corner which is a toggle with “Current post terms”. This option is available since Bricks 1.8.4 and is described in the Docs in the last paragraph here: Query Loop – Bricks Academy
For a quick showcase I’ve used the {post_id} and {term_id} but in a real life scenario those would get replaced by {post_title}, {term_name} or any custom fields attached to them.
@charaf could you or anyone from team consider adding an example in the mentioned Docs. Currently there’s a showcase of “Terms” query in Example 3, yet I believe that many people would appreciate the example of nested “Terms” inside of “Posts” in one or many following setups:
Posts loop with Tags loop inside
Products loop with product taxonomies/categories
Any CPT with any CTax (like property listings, portfolio with technology stack used, etc.)
Assuming that the inner loop gives more than one result, which would showcase how powerful Bricks is in terms (pun unintended) of nested loops setup.