get_post_type_labels

函式
get_post_type_labels ( $post_type_object )
Access
Private
引數
  • (object|WP_Post_Type) $post_type_object Post type object.
    Required:
返回值
  • (object) Object with all the labels as member variables.
定義位置
相關方法
get_post_typesget_post_type_objectget_post_typeget_post_type_capabilitiesget_post_type_archive_link
引入
3.0.0
棄用
-

get_post_type_labels函式是一個WordPress的函式,用於檢索一個指定的文章型別的標籤: 這個函式把文章型別的名稱作為引數,並返回一個標籤陣列。

從一個文章型別物件中建立一個包含所有文章型別標籤的物件。
在文章型別物件中接受標籤陣列的鍵。

– `name`-文章型別的一般名稱,通常是複數。相同的,並被
`$post_type_object->label`。預設為”文章”/”頁面”。
– `singular_name` – 這個文章型別的一個物件的名稱。預設為’文章’/’頁面’。
– `add_new` – 分層和非分層型別的預設值都是’新增新的’。
當國際化這個字串時,請使用一個{@link gettext context}來匹配你的文章型別。
匹配你的文章型別。例如:`_x( ‘Add New’, ‘product’, ‘textdomain’);`.
– `add_new_item` – 新增一個新的單項的標籤。預設為’新增新帖’/’新增新頁’。
– `edit_item` – 用於編輯一個單一專案的標籤。預設為’編輯文章’/’編輯頁面’。
– `new_item` – 新專案頁面標題的標籤。預設為’新文章’/’新頁面’。
– `view_item` – 用於檢視單一專案的標籤。預設為’檢視文章’/’檢視頁面’。
– `view_items` – 檢視文章型別存檔的標籤。預設為’檢視文章’/’檢視頁面’。
– `search_items` – 用於搜尋複數專案的標籤。預設為”搜尋文章”/”搜尋頁面”。
– `not_found` – 當沒有找到專案時使用的標籤。預設為”沒有找到文章”/”沒有找到頁面”。
– `not_found_in_trash` – 當回收站中沒有專案時使用的標籤。預設是’回收站中沒有發現文章’/’回收站中沒有發現頁面’。
‘回收站中沒有發現頁面’。
– `parent_item_colon` – 標籤,用於分層專案的父級字首。不用於非層次性的
文章型別。預設為”父頁:”。
– `all_items` – 標示子選單連結中所有專案的標籤。預設為”所有文章”/”所有頁面”。
– `archives` – 導航選單中檔案的標籤。預設為’文章檔案’/’頁面檔案’。
– `attributes` – 屬性元框的標籤。預設為”文章屬性”/”頁面屬性”。
– `insert_into_item` – 媒體框架按鈕的標籤。預設為’插入到文章’/’插入到頁面’。
– `uploaded_to_this_item` – 媒體框架過濾器的標籤。預設是’上載到這個文章’/’上載到這個頁面’。
‘上載到這個頁面’。
– `featured_image` – 特色圖片元框標題的標籤。預設為”特色圖片”。
– `set_featured_image` – 用於設定特色圖片的標籤。預設為”設定特色圖片”。
– `remove_featured_image` – 用於移除特色圖片的標籤。預設值是’移除特色圖片’。
– `use_featured_image` – 媒體框架中使用特色圖片的標籤。預設值是”作為特色圖片使用”。
– `menu_name` – 選單名稱的標籤。預設與`name’相同。
– `filter_items_list` – 表檢視隱藏標題的標籤。預設為’過濾文章列表’/’過濾頁面列表’。
‘過濾頁面列表’.
– `filter_by_date` – 列表表中的日期過濾器的標籤。預設為”按日期過濾”。
– `items_list_navigation` – 表格分頁的隱藏標題的標籤。預設為’文章列表導航’/’頁面列表導航’。
‘頁面列表導航’。
– `items_list` – 表的隱藏標題的標籤。預設為’文章列表’/’頁面列表’。
– `item_published` – 當一個專案被髮布時使用的標籤。預設為’文章釋出’。/ ‘頁面釋出’。
– `item_published_privately` – 當一個專案以私密的方式釋出時使用的標籤。
預設為’文章已私下發布’。/ ‘頁面私下發布’。
– `item_reverted_to_draft` – 當一個專案被轉換為草稿時使用的標籤。
預設為’文章恢復為草稿’。/ ‘頁面恢復為草稿’。
– `item_scheduled` – 當一個專案被計劃釋出時使用的標籤。預設為’文章已安排好’。/
‘頁面預定。
– `item_updated` – 當一個專案被更新時使用的標籤。預設是’文章更新’。/ ‘頁面更新’。
– `item_link` – 導航連結塊變化的標題。預設為’文章連結’/’頁面連結’。

– `item_link_description` – 導航連結塊的描述。預設為’一個文章的連結’。/
‘一個頁面的連結’。

以上,第一個預設值適用於非分層的文章型別(如文章),第二個預設值適用於分層的文章型別(如頁面)。

注意:要設定文章型別管理通知中使用的標籤,請參閱{@see ‘post_updated_messages’}過濾器。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_post_type_labels( $post_type_object ) {
$nohier_vs_hier_defaults = WP_Post_Type::get_default_labels();
$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
$post_type = $post_type_object->name;
$default_labels = clone $labels;
/**
* Filters the labels of a specific post type.
*
* The dynamic portion of the hook name, `$post_type`, refers to
* the post type slug.
*
* Possible hook names include:
*
* - `post_type_labels_post`
* - `post_type_labels_page`
* - `post_type_labels_attachment`
*
* @since 3.5.0
*
* @see get_post_type_labels() for the full list of labels.
*
* @param object $labels Object with labels for the post type as member variables.
*/
$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
// Ensure that the filtered labels contain all required default values.
$labels = (object) array_merge( (array) $default_labels, (array) $labels );
return $labels;
}
function get_post_type_labels( $post_type_object ) { $nohier_vs_hier_defaults = WP_Post_Type::get_default_labels(); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults ); $post_type = $post_type_object->name; $default_labels = clone $labels; /** * Filters the labels of a specific post type. * * The dynamic portion of the hook name, `$post_type`, refers to * the post type slug. * * Possible hook names include: * * - `post_type_labels_post` * - `post_type_labels_page` * - `post_type_labels_attachment` * * @since 3.5.0 * * @see get_post_type_labels() for the full list of labels. * * @param object $labels Object with labels for the post type as member variables. */ $labels = apply_filters( "post_type_labels_{$post_type}", $labels ); // Ensure that the filtered labels contain all required default values. $labels = (object) array_merge( (array) $default_labels, (array) $labels ); return $labels; }
function get_post_type_labels( $post_type_object ) {
	$nohier_vs_hier_defaults = WP_Post_Type::get_default_labels();

	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];

	$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );

	$post_type = $post_type_object->name;

	$default_labels = clone $labels;

	/**
	 * Filters the labels of a specific post type.
	 *
	 * The dynamic portion of the hook name, `$post_type`, refers to
	 * the post type slug.
	 *
	 * Possible hook names include:
	 *
	 *  - `post_type_labels_post`
	 *  - `post_type_labels_page`
	 *  - `post_type_labels_attachment`
	 *
	 * @since 3.5.0
	 *
	 * @see get_post_type_labels() for the full list of labels.
	 *
	 * @param object $labels Object with labels for the post type as member variables.
	 */
	$labels = apply_filters( "post_type_labels_{$post_type}", $labels );

	// Ensure that the filtered labels contain all required default values.
	$labels = (object) array_merge( (array) $default_labels, (array) $labels );

	return $labels;
}

常見問題

FAQs
檢視更多 >