Hello – I have a custom post type, and inside those posts, I have an ACF Select field.
I’m stuck on a query for being able to grab all of the posts from the CPT and display them grouped conditionally, if there are any posts within any given select value.
For instance, if there are 2 posts with an ACF Select field selection of Group 1, 1 that is in Group 3, and 3 in Group 7, would output:
I have it partially working now, but using multiple queries (not as efficient) and without the conditional checks, so not ideal.
Thanks for any insight
What is the current query you are using to get the posts without grouping?
Thanks John – I was just in the process of reworking so that I’m using custom taxonomy as opposed to using the ACF field at all for that. Should be good to go now. Appreciate the help.
Hey, i’m looking for that same thing. Can you post the solution here? Thanks.
@maidus – I wasn’t able to get the query for ACF select values to work, so I ended up doing custom taxonomies added to the post type, then doing individual queries for each. Was using this for populating the Isotope jQuery plugin for filtering products.
<?php $headstyles = get_categories('taxonomy=mag_filter&post_type=product'); ?>
<?php foreach ($headstyles as $headstyle) : ?>
<div class="option" data-filter=".<?php echo $headstyle->slug; ?>"><?php echo $headstyle->name; ?></div>
<?php endforeach; ?>