acf_get_post_types()
Returns an array of post type names.
Хуки из функции
Возвращает
Массив. A list of post type names.
Использование
acf_get_post_types( $args );
- $args(массив)
- An array of key => value arguments to match against the post type objects.
По умолчанию:empty array
Список изменений
| С версии 5.0.0 | Введена. |
Код acf_get_post_types() acf get post types ACF 6.4.2
function acf_get_post_types( $args = array() ) {
$post_types = array();
// extract special arg
$exclude = acf_extract_var( $args, 'exclude', array() );
$exclude[] = 'acf-field';
$exclude[] = 'acf-field-group';
$exclude[] = 'acf-post-type';
$exclude[] = 'acf-taxonomy';
$exclude[] = 'acf-ui-options-page';
// Get post type objects.
$objects = get_post_types( $args, 'objects' );
foreach ( $objects as $i => $object ) {
// Bail early if is exclude.
if ( in_array( $i, $exclude ) ) {
continue;
}
// Bail early if is builtin (WP) private post type
// i.e. nav_menu_item, revision, customize_changeset, etc.
if ( $object->_builtin && ! $object->public ) {
continue;
}
$post_types[] = $i;
}
return apply_filters( 'acf/get_post_types', $post_types, $args );
}