Enter your keyword

Blog

ACF Repeater field value in WP_Query

/*  Add in theme functions.php file */
function class_schedule_posts_where( $where ) {
   $where = str_replace("meta_key = 'class_schedule_$", "meta_key LIKE 'class_schedule_%", $where);
   return $where;
}
add_filter( 'posts_where', 'class_schedule_posts_where' );

/* WP_Query  */
$arr_posts = array(
	   'posts_per_page' => -1,
	   'post_type'		=> 'class',
	   'post_status' 	=> array('publish'),
	   'meta_key'      	=> 'class_schedule_$_class_time',
	   'orderby'     	=> 'meta_value_num',
	   'order'       	=> 'ASC',
	   'meta_query'     => array(
			                array(
			                  'key'     => 'class_schedule_$_class_day',
			                  'compare' => '=',
			                  'value'   => $arrayDays[$d],
			                ),
	             		 ),          
	    );
$wp_query = new WP_Query($arr_posts); 

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.