acf_field_group_has_location_type()
Checks if a field group has the provided location rule.
Хуков нет.
Возвращает
true|false.
Использование
acf_field_group_has_location_type( $post_id, $location );
- $post_id(int) (обязательный)
- The post ID of the field group.
- $location(строка) (обязательный)
- The location type to check for.
Список изменений
| С версии 6.2.8 | Введена. |
Код acf_field_group_has_location_type() acf field group has location type ACF 6.4.2
function acf_field_group_has_location_type( int $post_id, string $location ) {
if ( empty( $post_id ) || empty( $location ) ) {
return false;
}
$field_group = acf_get_field_group( (int) $post_id );
if ( empty( $field_group['location'] ) ) {
return false;
}
foreach ( $field_group['location'] as $rule_group ) {
$params = array_column( $rule_group, 'param' );
if ( in_array( $location, $params, true ) ) {
return true;
}
}
return false;
}