ACF_Location_Post::get_valuespublicACF 5.9.0

Returns an array of possible values for this rule type.

Method of the class: ACF_Location_Post{}

No Hooks.

Returns

Array.

Usage

$ACF_Location_Post = new ACF_Location_Post();
$ACF_Location_Post->get_values( $rule );
$rule(array) (required)
A location rule.

Changelog

Since 5.9.0 Introduced.

ACF_Location_Post::get_values() code ACF 6.0.4

public function get_values( $rule ) {
	$choices = array();

	// Get post types.
	$post_types = acf_get_post_types(
		array(
			'show_ui' => 1,
			'exclude' => array( 'page', 'attachment' ),
		)
	);

	// Get grouped posts.
	$groups = acf_get_grouped_posts(
		array(
			'post_type' => $post_types,
		)
	);

	// Append to choices.
	if ( $groups ) {
		foreach ( $groups as $label => $posts ) {
			$choices[ $label ] = array();
			foreach ( $posts as $post ) {
				$choices[ $label ][ $post->ID ] = acf_get_post_title( $post );
			}
		}
	}
	return $choices;
}