This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_post_type_object/
Languages: English • Italiano • (Add your language)
Recupera un oggetto che descrive qualunque tipo di post registrato (ad esempio tipi predefiniti come 'post' e 'page', o qualunque tipo di post personalizzato creato dall'utente).
<?php get_post_type_object( $post_type ); ?>
Nulla in caso di fallimento (es. può verificare la presenza di null).
$obj = get_post_type_object( 'post' ); echo $obj->labels->singular_name;
Tecnicamente, è equivalente a
global $wp_post_types; $obj = $wp_post_types['post']; echo $obj->labels->singular_name;
print_r( $obj ) potrebbe restituire un oggetto di questo tipo:
stdClass Object
(
[labels] => stdClass Object
(
[name] => Articoli
[singular_name] => Articolo
[add_new] => Aggiungi nuovo
[add_new_item] => Aggiungi nuovo articolo
[edit_item] => Modifica articolo
[new_item] => Nuovo articolo
[view_item] => Visualizza articolo
[search_items] => Cerca articoli
[not_found] => Nessun articolo trovato
[not_found_in_trash] => Nessun articolo trovato nel cestino
[parent_item_colon] =>
)
[description] =>
[publicly_queryable] => 1
[exclude_from_search] =>
[_builtin] => 1
[_edit_link] => post.php?post=%d
[capability_type] => post
[hierarchical] =>
[public] => 1
[rewrite] =>
[query_var] =>
[register_meta_box_cb] =>
[taxonomies] => Array
(
)
[show_ui] => 1
[menu_position] =>
[menu_icon] =>
[permalink_epmask] => 1
[can_export] => 1
[show_in_nav_menus] => 1
[name] => post
[cap] => stdClass Object
(
[edit_post] => edit_post
[edit_posts] => edit_posts
[edit_others_posts] => edit_others_posts
[publish_posts] => publish_posts
[read_post] => read_post
[read_private_posts] => read_private_posts
[delete_post] => delete_post
)
[label] => Articoli
)
Si noti che i nomi degli attributi dell'oggetto sono leggermente differenti rispetto agli argomenti attesi dalla funzione register_post_type().
get_post_type_object() si trova in wp-includes/post.php.
Tipi di post: register_post_type(), add_post_type_support(), remove_post_type_support(), post_type_supports(), post_type_exists(), set_post_type(), get_post_type(), get_post_types(), get_post_type_object(), get_post_type_capabilities(), get_post_type_labels(), is_post_type_hierarchical(), is_post_type_archive(), post_type_archive_title()