get_all_category_ids()
Deprecated since 4.0.0. It is no longer supported and may be removed in future releases. Use get_terms() instead.
Gets the identifiers (ID) of all categories.
From version 4.0 and above, the function is deprecated, use get_terms() instead.
Returns an array containing the IDs of all categories.
Uses: get_terms()
No Hooks.
Returns
Int[].
Usage
$category_ids = get_all_category_ids();
Examples
#1 Display the list of category IDs and their names, in the format identifier:name
$category_ids = get_all_category_ids();
foreach( $category_ids as $cat_id ){
$cat_name = get_cat_name( $cat_id );
echo "{$cat_id}: {$cat_name}<br />";
}
Notes
- See: get_terms()
Changelog
| Since 2.0.0 | Introduced. |
| Deprecated since 4.0.0 | Use get_terms() |
get_all_category_ids() get all category ids code WP 7.0
function get_all_category_ids() {
_deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' );
$cat_ids = get_terms(
array(
'taxonomy' => 'category',
'fields' => 'ids',
'get' => 'all',
)
);
return $cat_ids;
}