Can I delimit a ACF custom post type with taxonomy choices made in a separate repeater?

I have two loops going but I’m trying to have one delimit the other. Is that possible? Here’s what I mean.

I have Field Group (Topics) that is a Repeater and includes 3 subfields: two text fields and a Taxonomy field using Category (where checkboxes allow you to select Categories). It’s set to appear on every Page admin.

Then, I also have Custom Post type (Resources) that is fed by different Field Group (Resource Items) that contains 3 fields, one of which is a Taxonomy field using the same set of Categories as the Topics field group.

So, in the WP admin for a Page, you see the Topics Repeater, and you can add different topics by adding rows. In each repeater, you add text to the two text fields but you also check which Category or Categories that text content is relevant to.

So far so good. Now, on the Cornerstone build, two columns: The left loops the two text fields in the Topics field group. The right loops the contents of the Resources custom post type.

BUT my problem: I want to delimit which Resources appear by what categories were chosen in the Topics repeater.

How do I set up a Dynamic Content query to pull this in? It would be sort of like:

{{dc:looper:field key=“resources” field=“ {{category you checked in the Topic repeater}}” }}

Is there a way to do that with the tools inside Cornerstone? Any advice or resources appreciated.

Hello Matt,

Thanks for the very detailed post information. you will have to use Looper Provider Query String with the following arguments:

$args = array(
  'post_type' => 'resource',
  'tax_query' => array(
    array(
      'taxonomy' => 'resource-category',
      'field' => 'term_id',
      'terms' => '{{dc:looper:field key="resource_categories"}}',
      'operator' => 'IN',
    ),
  ),
);

Please check out this tutorial in creating a query string:

Best Regards.

Thanks so much for this, Rue. Unfortunately, building a query string is new to me, so I don’t exactly know what to do with this. I’ve placed the code above in my functions.php file, as Kory recommends, but how I do I translate that (call that) into a looper query string in Cornerstone?

I’ve taken a stab at turning the arguments above into a query string (based on Kory’s example):

post_type=resource&tax_query%5B0%5D%5Btaxonomy%5D=resource-category&tax_query%5B0%5D%5Bfield%5D=term_id&tax_query%5B0%5D%5Bterms%5D={{dc:looper:field key="resource_categories"}}&tax_query%5B0%5D%5Boperator%5D=IN

and pasted it into the Looper field, but nothing happens…

Hey Matt,

I seem to no longer see the ACF fields on your homepage. Did you change something or plan to create another way of displaying the related resources? Please give further clarifications if you go forward.

Thank you.

Yes, I’m afraid I ran out of time and had to rig it all manually. But this would be great to solve (if you think it can), so I’ll create a page and let you know.

Hey Matt,

That’s great and let us know how it goes.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.