Use a ACF key and value as a provider

Hello - I’ve worked through a number of forum posts to try and get a provider to work with no luck.

I’m trying to get a provider on this page to show products that have a ‘AHJ - Fire Code Administrators’ value for the key ‘florida_audience’ from ACF:

This is the page with the provider:

These are the posts I’ve worked through with no luck:



Right now this is the code I’m using:
post_type=product&meta_key=florida_audience&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bkey%5D=florida_audience&meta_query%5B0%5D%5Bvalue%5D=ahj-fire-code-administrators&meta_query%5B0%5D%5Bcompare%5D=%3D%3D

I’ve also tried:
post_type=product&meta_key=florida_audience&meta_value=AHJ±+Fire+Code+Administrators

And:
post_type=product&meta_query%5B0%5D%5Bkey%5D=florida_audience&meta_query%5B0%5D%5Bvalue%5D=AHJ±+Fire+Code+Administrators&meta_query%5B0%5D%5Bcompare%5D=%3D

Any help with next steps?

Hey @coxdigitalarts,

Thanks for reaching out!

I am still uncertain on your goal, would you mind sharing more information so that we can fully understand your query? On the other hand, the given credential is not working, please update them with the correct ones.

Thank you.

I’m sorry for not explaining well. I’m trying to enable a provider on a row to pull specific products. Using ACF, I have a dropdown enabled on products with a field labeled “Florida Audience”. I’d like to pull all products marked as one of the options (AHJ - Fire Code Administrators). I’m trying to query all products with a value of “ AHJ - Fire Code Administrators” on the Florida Audience meta key.

Attaching the correct login.

Hey @coxdigitalarts,

Regretfully, the given user details still do not work for us.

Meanwhile, your query argument should be like this:

$meta_query[] = array(
    'key' => 'florida_audience',
    'value' => 'AHJ - Fire Code Administrators',
    'compare' => '='
);

$args = array(
  'post_type' => 'product',
  'orderby'    => 'meta_value',
  'order'      => 'DESC',
  'meta_query' => $meta_query
);

which should give something like:
post_type=product&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bkey%5D=florida_audience&meta_query%5B0%5D%5Bvalue%5D=AHJ+-+Fire+Code+Administrators&meta_query%5B0%5D%5Bcompare%5D=%3D

Kindly let us know how it goes.

Thanks @ruenel - Unfortunately, it still didn’t work. I’m reattaching the credentials. I’ve verified these are working. For some reason the first time I copied these in, the asterisks were removed.

I suspect the issue is that my ACF field is in a group. When I view the keys on a product with my desired selection enabled, this is what I’m seeing for key and value:
Florida Audience_florida_audience : a:6:{i:0;s:26:“Sprinkler Contractor 1 & 2”;i:1;s:22:“Sprinkler Contractor 4”;i:2;s:22:“Sprinkler Contractor 5”;i:3;s:30:“AHJ - Fire Code Administrators”;i:4;s:29:“AHJ - Fire Safety Inspector 1”;i:5;s:22:“Water Based Inspectors”;}

I tried including the group name as well with no luck:
post_type=product&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bkey%5D=Florida+Audience_florida_audience&meta_query%5B0%5D%5Bvalue%5D=AHJ±+Fire+Code+Administrators&meta_query%5B0%5D%5Bcompare%5D=%3D

For testing purposes, I’ve also enabled all keys and values to show in the head of the page:

Thanks very much for your help with this!

Side note - the forum here keeps striping out special characters from my secure note. I just changed my password to contain no special characters (asterisks seemed to be the issue). I’ve updated to my new password in the secure note.

Hello @coxdigitalarts,

The query is not working all because of the naming of your field name:

Using the current names, the query argument will be:

$args = array(
    'post_type' => 'product',
    'meta_query' => array(
        array(
            'key' => 'Florida Audience_florida_audience',
            'value' => 'AHJ - Fire Code Administrators',
            'compare' => 'LIKE'
        )
    )
);

This should a query string of:
post_type=product&meta_query%5B0%5D%5Bkey%5D=Florida+Audience_florida_audience&meta_query%5B0%5D%5Bvalue%5D=AHJ+-+Fire+Code+Administrators&meta_query%5B0%5D%5Bcompare%5D=LIKE

Please be very careful with your field names. There should NOT be any space or special characters to avoid any issues.
Be advised that custom and complex queries are beyond the scope of our support under our Support Policy. If you are unfamiliar with setting field names, code, queries, and resolving potential conflicts, you may select our One service for further assistance.

Best Regards.

@ruenel - you all freakin rock!!! I’m constantly impressed with you guys.

Thanks for all your help!

You are most welcome.

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