I’ve found a “round-a-bout” way to do this… I run the query without the banner_cats and banner_towns conditions (and get rid of the posts_per_page). This will pull alot more results… Then, during the while loop, I check each post for an array_intersect for each meta keys. Since I only want 1 result, I break the loop if one is found.
While the solution works, I’d prefer to do this during the query process (to save resources)
The two trim errors are coming up when the two keys are involved (banner_cats and banner_towns). So, if I remove one of those arrays from the query, only one trim error occurs. Both of those keys are multi select fields in acf.
When I print the $pagecategories array (to check it), I get…
Array (  => 1 )
When I print $currenttowns array, I get…
Array (  => 1  => 3215 )
So, I have one array (i.e. $currenttowns) comparing to the select field array (i.e. banner_towns) … can I not do that? I need to see if any of the fields in the arrays match, if so, then the query should call that post.
I’ve cleaned things up a bit… but now I’m getting an trim error from the meta.php file…
Here is the error..
Warning: trim() expects parameter 1 to be string, array given in /home/tipsfromtown/public_html/wp-includes/meta.php on line 1432
Since I’ve already closed this topic (cause the initial problem was fixed), and noone is responding to this thread anymore, I’ll open a new one with my code…
I used get_post_meta to pull the info. Below are the results for social_media_script2 …..
[social_media_script2] => Array (  => <div class="fb-activity" data-site="http://ridgewood.tipsfromtown.com" data-action="likes, recommends" data-width="100%" data-height="400px" data-colorscheme="light" data-header="true"></div> ) [_social_media_script2] => Array (  => field_530b8d2cb5ff9 )
The output is only
I know it’s not an ID issue, since the page is loading other values from ACF on the page.
I also used get_post_meta to see the values in the database for side_feature …
`[side_feature_0_side_feature_img] => Array
 => 50633
[_side_feature_0_side_feature_img] => Array
 => field_530b8c7eb5ff4
[side_feature_0_side_feature_txt] => Array
 => Ridgewood
[_side_feature_0_side_feature_txt] => Array
 => field_530b8c9cb5ff5
[side_feature_0_side_feature_url] => Array
 => http://www.somewhere.com/2
[_side_feature_0_side_feature_url] => Array
 => field_530b8cb5b5ff6
[side_feature] => Array
 => 2
[_side_feature] => Array
 => field_530b8c5eb5ff3
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!