I have the following setup in the admin of sb_affiliation (repeater) and sub-items of the sb_state & sb_url.
I followed one of your given codes here.
// Filter
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'sb_affiliation_$", "meta_key LIKE 'sb_affiliation_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// Vars
$sb_state = 'XX';
// Args
$args = array(
'numberposts' => -1,
'post_type' => 'sportsbooks',
'has_password' => false,
'order' =>'asc',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'sb_affiliation_$_sb_state',
'compare' => '=',
'value' => $_COOKIE['state_abbr'],
)
)
);
// Query
$the_query = new WP_Query( $args );
while this is the code for the query.
while ( $the_query->have_posts() ) : $the_query->the_post();
$image = get_field('sb_image');
$promo = get_field('sb_promotion');
$details = get_field('sb_details');
while ( have_rows('sb_affiliation') ) :
the_row();
$states = get_sub_field('sb_state');
$urls = get_sub_field('sb_url');
if ( $_GET['state_abbr'] != $states && $_COOKIE['state_abbr'] != $states )
continue;
$state = $states;
$url = $urls;
endwhile;
// My HTML Codes Goes Here...
endwhile;
wp_reset_query();
The problem i am having here was the meta_query. How can get it in correct format to be able to match the cookie/parameter of state_abbr
to sb_state
.