Enter your keyword

ACF Plugin

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

How to Order by Advanced Custom field in WP_QUERY

function my_pre_get_posts( $query ) {
	// do not modify queries in the admin
	if( is_admin() ) {	
		return $query;	
	}
	
	// only modify queries for 'event' post type
	if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'event' ) {
		$query->set('orderby', 'meta_value');	
		$query->set('meta_key', 'p_start_date');	 
		$query->set('order', 'ASC'); 		
	}
		// return
	return $query;

}

add_action('pre_get_posts', 'my_pre_get_posts');

How to Add Option Page in Advanced Custom Fields Plugin

 if(function_exists(acf_add_options_page))
{
	acf_add_options_sub_page(array(
	  'page_title'  => 'Theme General Settings',
	  'menu_title' => 'Theme Settings',
	  'parent_slug' => 'themes.php',
	  'menu_slug'  => 'theme-general-settings',
	  'capability' => 'edit_posts',
	  'redirect'  => false
	));
}