カスタム投稿タイプの情報を取得

WordPress

カスタム投稿タイプの名前を取得

$post_type = get_post_type( $post );
500 Internal Server Error

 

カスタム投稿タイプの情報を取得

$post_type_object = get_post_type_object( $post_type );
echo $post_type_object -> labels -> name;//名前
echo $post_type_object -> label;//名前(上と同じ?)
500 Internal Server Error
stdClass Object
(
    [labels] => stdClass Object
        (
            [name] => お知らせ// カスタム投稿タイプの名称(ラベル)
            [singular_name] => お知らせ
            [add_new] => お知らせを追加
            [add_new_item] => 新しいお知らせを追加
            [edit_item] => お知らせを編集
            [new_item] => 新しいお知らせ
            [view_item] => お知らせを編集
            [search_items] => お知らせを探す
            [not_found] => お知らせはありません
            [not_found_in_trash] => ゴミ箱にお知らせはありません
            [parent_item_colon] => 
        )
 
    [description] => 
    [publicly_queryable] => 1
    [exclude_from_search] => 
    [_builtin] => 
    [_edit_link] => post.php?post=%d
    [capability_type] => post
    [hierarchical] => 
    [public] => 1
    [rewrite] => Array
        (
            [slug] => information// 投稿タイプのスラッグ(名前)
            [with_front] => 1
        )
 
    [query_var] => information
    [register_meta_box_cb] => 
    [taxonomies] => Array// 紐付けされているタクソノミー
        (
            [0] => information_type
        )
 
    [show_ui] => 1
    [menu_position] => 2
    [menu_icon] => 
    [permalink_epmask] => 1
    [can_export] => 1
    [show_in_nav_menus] => 1
    [name] => information// 投稿タイプの名前(スラッグ)
    [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] => お知らせ// カスタム投稿タイプの名称(ラベル)
)

 

タイトルとURLをコピーしました