-1, 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => 'any', 'suppress_filters' => false, 'update_post_meta_cache' => false )); if( $posts ){ // sort into hierachial order! if( is_post_type_hierarchical( 'page' )){ $posts = get_page_children( 0, $posts ); } foreach( $posts as $page ){ $title = ''; $ancestors = get_ancestors($page->ID, 'page'); if($ancestors){ foreach($ancestors as $a){ $title .= '- '; } } $title .= apply_filters( 'the_title', $page->post_title, $page->ID ); // status if($page->post_status != "publish"){ $title .= " ($page->post_status)"; } $choices[ $page->ID ] = $title; } } return $choices; } public function acf_rule_match_grandchild( $match, $rule, $options ){ if( !$options['post_id'] || 'page' !== get_post_type( $options['post_id']) ) return false; $parent = get_ancestors( $options['post_id'], 'page' ); $grandparent = !empty($parent[1])? $parent[1]: null; if( $grandparent ){ $is_grandparent = ($rule['value'] == $grandparent)? $grandparent: null; if ( '==' == $rule['operator'] ) { $match = $is_grandparent; } elseif ( '!=' == $rule['operator'] ) { $match = ! $is_grandparent; } } return $match; } } new acf_page_grandchildren;