Yes, I double checked just now. But I did add it.
function add_cond_to_where( $where ) {
$where = str_replace("meta_key = 'data_$", "meta_key LIKE 'data_%", $where);
return $where;
}
add_filter('posts_where', 'add_cond_to_where');
Is in my functions.php. Anyway I can test if it works?
The repeater field is called data and the the subfield is called startdatum. I just translated it in my origional post so it would be easier to understand.
Does it have anything to do with the fact that I run it from a code snippet made with the code snippets plugin? Or do you know anyone who would know what’s wrong? I could really use the help
No I didn’t translate the code this time! It’s dutch. I didn’t change the meta_key.
$today = date('Ymd');
But it worked like a charm with _0_ for just the first value. Now $posts finds 0 values. I also tried to change the comparer to ‘<‘ but that did not work.
I added
function add_cond_to_where( $where ) {
//Replace showings_$ with repeater_slug_$
$where = str_replace("meta_key = 'data_$", "meta_key LIKE 'data_%", $where);
return $where;
}
to my functions.php and set supress filters to false like so
$posts = get_posts(array(
'numberposts' => $limit,
'post_type' => 'opleidingen',
'orderby' => 'meta_value',
'suppress_filters' => 'false',
'meta_query' => array(
array(
'key' => 'data_$_startdatum',
'value' => $today,
'compare' => '>',
)
),
'order' => $order,
));
But it’s getting 0 results?
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.