説明
object get_post_type_labels( object|WP_Post_Type $post_type_object )
投稿タイプのラベルを取得する。
パラメータ
- $post_type_object投稿タイプ情報のオブジェクトを指定。
返り値
投稿タイプのラベルをオブジェクトで返す。いくつかのバージョンでラベルデータが追加されている。
| プロパティ名 | バージョン | 内容('投稿'の場合) |
|---|---|---|
| name | 3.0.0 | 'Posts' |
| singular_name | 3.0.0 | 'Post' |
| add_new | 3.0.0 | 'Add New' |
| add_new_item | 3.0.0 | 'Add New Post' |
| edit_item | 3.0.0 | 'Edit Post' |
| new_item | 3.0.0 | 'New Post' |
| view_item | 3.0.0 | 'View Post' |
| search_items | 3.0.0 | 'Search Posts' |
| not_found | 3.0.0 | 'No posts found.' |
| not_found_in_trash | 3.0.0 | 'No posts found in Trash.' |
| parent_item_colon | 3.0.0 | null |
| all_items | 3.0.0 | 'All Posts' |
| menu_name | - | 'Posts' |
| name_admin_bar | - | 'Post' |
| featured_image | 4.3.0 | 'Featured Image' |
| set_featured_image | 4.3.0 | 'Set featured image' |
| remove_featured_image | 4.3.0 | 'Remove featured image' |
| use_featured_image | 4.3.0 | 'Use as featured image' |
| archives | 4.4.0 | 'Post Archives' |
| insert_into_item | 4.4.0 | 'Insert into post' |
| uploaded_to_this_item | 4.4.0 | 'Uploaded to this post' |
| filter_items_list | 4.4.0 | 'Filter posts list' |
| items_list_navigation | 4.4.0 | 'Posts list navigation' |
| items_list | 4.4.0 | 'Posts list' |
| view_items | 4.7.0 | 'View Posts' |
| attributes | 4.7.0 | 'Post Attributes' |
| item_published | 5.0.0 | 'Post published.' |
| item_published_privately | 5.0.0 | 'Post published privately.' |
| item_reverted_to_draft | 5.0.0 | 'Post reverted to draft.' |
| item_scheduled | 5.0.0 | 'Post scheduled.' |
| item_updated | 5.0.0 | 'Post updated.' |
注意
テーマやプラグインで本関数を呼び出す機会は少ない。 register_post_type関数で登録した投稿タイプのラベル(連想配列のキーとその内容)を確認できる。
'固定ページ'の場合、parent_item_colonプロパティは'Parent Page:'となる。親子関係のあるカスタム投稿タイプの場合は要注意。
使用例
- 投稿タイプのラベルを取得する。
<?php $labels = get_post_type_labels( $post_type_pbject ); ?>
フィルター
[3.5.0]デフォルトのラベルとマージする前に"post_type_labels_{$post_type}"フィルターを呼び出す。$labelsにはパラメータ$post_type_pbjectから取得したラベルのオブジェクトが格納されている。$labels = apply_filters( "post_type_labels_{$post_type}", $labels );アクション
実行するアクションはありません。ソースファイル
/wp-includes/post.php最終更新 : 2018年12月07日 09:57
関連
お勧め
meta_compare_key使ってみた(2019年3月19日 更新)
ブロックエディターの登場により、標準のカスタムフィールドを使う機会はかなり減った気がする。そんな中、5.1.0で追加されたのが、カスタムフィールド名(メタキー)に含まれる文字列を指定する'meta_compare_key'キーだ。
WP_List_Tableクラスの「一括操作」フォームを使ってみた(2018年5月27日 更新)
今回は「WP_List_Tableクラスを使ってみた」の続き。投稿一覧やプラグインページなどにある「一括操作」(Bulkアクション)フォーム対応に関するメモである。
テーマから投稿画像のサイズを指定する(2012年3月15日 更新)
投稿記事に挿入する画像サイズは、サムネイル(150×150)、中サイズ(300×300)、大サイズ(1024×1024)がデフォルトだが、テーマによっては別のサイズを指定したい場合はある。基本的には、「設定」-「メディア」の「メディア設定」ページで指定できるが、テーマ内のfunctions.phpで設定しておくとちょっと便利かもしれない。ログインページを変える(2014年9月12日 更新)
WordPressの標準的な不正ログイン対策としては、ログインIDは'admin'を避けるパスワードはユニークで長くする、場合によってはアクセスできるIPアドレスを制限する、といった具合だろう。これらの他に何かできないものだろうかと、ちょっと考えてみた。新規投稿時の本文プレースホルダーテキストを変える(2021年9月9日 更新)
ブロックエディターに影響を与えるフィルターは多数存在する。今回紹介するフィルターはその1つで、新規投稿時の本文ブロックのプレースホルダーテキストを変更するものだ。