Support

Account

Home Forums Add-ons Repeater Field Repeater Query Issue in WP 4.8.3 Reply To: Repeater Query Issue in WP 4.8.3

  • Has anyone figured out how to do this dynamically for multiple keys and values. I tried something like this (below) but I can’t get it to work.

    I have quite a few fields I need to be filtering for. I can get each field to work one at a time, but the second I try to do more than one, I see only field being filtered when i run “echo $GLOBALS[‘wp_query’]->request;”

    Any help would be HUGE. I have been stuck on this for quite some time! Thank you in advance.

    
    		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;
    			} */
    
    			$rootkeys[] = $_GET;
    			global $wpdb; //TESTING
    			foreach($rootkeys as $rootkey) {
    				foreach($rootkey as $key => $value) {
    					$partialkey = explode("$",$key);
    					$keya = $partialkey[0];
    					$keyb = 'meta_key = \''.$keya.'$';
    					$keyc = 'meta_key LIKE \''.$keya.'%'; //this = was LIKE, should it be?
    			// $where = str_replace($keyb, $keyc, $where);
    			$where = str_replace($keyb, $keyc, $wpdb->remove_placeholder_escape($where));
    			}
    			}
    			return $where;
    
    		}