Home › Forums › Add-ons › Repeater Field › Dynamically get meta_key fix for esc_sql() change in wp 4.8.3 › Reply To: Dynamically get meta_key fix for esc_sql() change in wp 4.8.3
Hey guys, I almost had it figured out. I don’t know why I didn’t think of just using a $GET. So as long as 1 filter is selected at a time, it now works. But the second that I select a filter, and a medical_use (url of something like ” strains?feelings_$_feeling=Euphoric&medical_use_$_medical=Seizures ”
Does anyone have any idea how I can get this to work for any meta_query in the URL?
add_filter('posts_where', 'my_posts_where');
function my_posts_where( $where ) {
if( isset($_GET['feelings_$_feeling']) ) {
$where = str_replace("meta_key = 'feelings_$", "meta_key LIKE 'feelings_%", $where);
return $where;
}
if( isset($_GET['medical_use_$_medical']) ) {
$where = str_replace("meta_key = 'medical_use_$", "meta_key LIKE 'medical_use_%", $where);
return $where;
}
return $where;
}
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.