Post Written by

WordPress get all category ids

To get all the category id’s from current wordpress blog you have to use following function which returns an array of all the category id’s

<?php $all_category_ids=get_all_category_ids() ?>

after that you can fetch to retrieve all the category ids. even you can get category name for each category.

$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 />';


WordPress Codex
Hire a WordPress Expert for your website to create wordpress themes