获取所有分类id

Published
2022-12-16
浏览次数 :  19

/*-----------------------------------------------------------------------------------*/
# Get All Categories IDs
/*-----------------------------------------------------------------------------------*/
function tie_get_all_category_ids(){
	$categories = array();
	$get_cats = get_terms( 'category' );
	if ( ! empty( $get_cats ) && ! is_wp_error( $get_cats ) ){
		foreach ( $get_cats as $cat )
			$categories[] = $cat->term_id;
	}
	return $categories;
}

  • 标签1
  • 标签1
  • 标签1
Top