Support

Account

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;
    }