WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

acf_maybe_get_field() ACF 5.2.3

acf_get_object_field

This function will return a field for the given selector. It will also review the field_reference to ensure the correct field is returned which makes it useful for the template API

Хуков нет.

Возвращает

$field. (array)

Использование

acf_maybe_get_field( $selector, $post_id, $strict );
$selector (обязательный)
-
$post_id **
-
По умолчанию: false
$strict **
-
По умолчанию: true

Список изменений

С версии 5.2.3 Введена.

Код acf_maybe_get_field() ACF 5.9.1

<?php
function acf_maybe_get_field( $selector, $post_id = false, $strict = true ) {
	
	// init
	acf_init();
	
	// Check if field key was given.
	if( acf_is_field_key($selector) ) {
		return acf_get_field( $selector );
	}
	
	// Lookup field via reference.
	$post_id = acf_get_valid_post_id( $post_id );
	$field = acf_get_meta_field( $selector, $post_id );
	if( $field ) {
		return $field;
	}
	
	// Lookup field loosely via name.
	if( !$strict ) {
		return acf_get_field( $selector );	
	}
	
	// Return no result.
	return false;
}