acf_get_post_types() ACF 5.0.0
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 5.9.1
function acf_get_post_types( $args = array() ) {
// vars
$post_types = array();
// extract special arg
$exclude = acf_extract_var( $args, 'exclude', array() );
$exclude[] = 'acf-field';
$exclude[] = 'acf-field-group';
// get post type objects
$objects = get_post_types( $args, 'objects' );
// loop
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
// - nav_menu_item, revision, customize_changeset, etc
if( $object->_builtin && !$object->public ) continue;
// append
$post_types[] = $i;
}
// filter
$post_types = apply_filters('acf/get_post_types', $post_types, $args);
// return
return $post_types;
}