wp_category_checklist

函式
wp_category_checklist ( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true )
引數
  • (int) $post_id Optional. Post to generate a categories checklist for. Default 0. $selected_cats must not be an array. Default 0.
    Required:
  • (int) $descendants_and_self Optional. ID of the category to output along with its descendants. Default 0.
    Required:
  • (int[]|false) $selected_cats Optional. Array of category IDs to mark as checked. Default false.
    Required:
    Default: false
  • (int[]|false) $popular_cats Optional. Array of category IDs to receive the "popular-category" class. Default false.
    Required:
    Default: false
  • (Walker) $walker Optional. Walker object to use to build the output. Default is a Walker_Category_Checklist instance.
    Required:
    Default: null
  • (bool) $checked_ontop Optional. Whether to move checked items out of the hierarchy and to the top of the list. Default true.
    Required:
    Default: true
相關
  • wp_terms_checklist()
定義位置
相關方法
wp_link_category_checklistwp_terms_checklistcategory_existswp_popular_terms_checklistupdate_category_cache
引入
2.5.1
棄用
-

wp_category_checklist: 這是一個函式,顯示一個分層的覈取方塊列表,用於為文章選擇類別。它可以用來讓使用者輕鬆地選擇和分配類別給他們的文章。

輸出一個無序的覈取方塊輸入元素列表,並標明類別名稱。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
wp_terms_checklist(
$post_id,
array(
'taxonomy' => 'category',
'descendants_and_self' => $descendants_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => $popular_cats,
'walker' => $walker,
'checked_ontop' => $checked_ontop,
)
);
}
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { wp_terms_checklist( $post_id, array( 'taxonomy' => 'category', 'descendants_and_self' => $descendants_and_self, 'selected_cats' => $selected_cats, 'popular_cats' => $popular_cats, 'walker' => $walker, 'checked_ontop' => $checked_ontop, ) ); }
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
	wp_terms_checklist(
		$post_id,
		array(
			'taxonomy'             => 'category',
			'descendants_and_self' => $descendants_and_self,
			'selected_cats'        => $selected_cats,
			'popular_cats'         => $popular_cats,
			'walker'               => $walker,
			'checked_ontop'        => $checked_ontop,
		)
	);
}

常見問題

FAQs
檢視更多 >