I'm working with a couple of plugins that ask for a list of category IDs to include/exclude.

When I go to the categories section and select "Edit" I don't see an ID field listed on the page, though I see all the other details. Since I will be relaying this information onto other users, how can I find the category ID for them?

2 Answers 2


there are some plugins that reveal the ID's on the admin side like WP Show IDs

and by code like this:

                  //as dropdown
$categories=  get_categories(array('hide_empty' => 0,'taxonomy' => 'category')); 
 echo '<select>';
  foreach ($categories as $category) {

    $option = '<option value="'.$category->category_id.'">';
    $option .= $category->cat_name;
    $option .= '</option>';
    echo $option;
  echo '</select>';

  //or just print the categories names  by ids like this

  $categories=  get_categories(array('hide_empty' => 0,'taxonomy' => 'category')); 

  foreach ($categories as $category) {

    echo $category->category_id;
    echo $category->cat_name;

  • That plugin is perfect! Since the end user isn't tech saavy, I can simply add it to the site. Thanks!
    – Dillie-O
    Jan 18, 2011 at 16:47
  • glad to help, any time :)
    – Bainternet
    Jan 18, 2011 at 17:11

Showing the IDs is pretty simple, you need to hook onto the table heading and columns for that taxonomy's management page.

I previously discussed this in a support topic here.

First hook onto the taxonomy table heading and add the new heading into the columns array.

function category_id_head( $columns ) {
    $columns['term_id'] = __('ID');
    return $columns;

add_filter( 'manage_edit-category_columns', 'category_id_head' );

Then hook onto the taxonomy table rows and output the term IDs.

function category_id_row( $output, $column, $term_id ){
    if( $column != 'term_id')
        return $output;
    return $term_id;

add_filter( 'manage_category_custom_column', 'category_id_row', 10, 3 );

You can of course always use a plugin, but for such a small amount of code that seems a bit silly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.