Support » Fixing WordPress » List categories by ID

  • Resolved markross1967


    Could someone please tell me how I can generate a list of ALL my post categories by ID?

    Thank you,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try this:

    $cats = get_terms('category','hide-empty=0&orderby=id');
    foreach ( $cats as $cat ) {
       echo "ID:$cat->term_id NAME:$cat->name SLUG:$cat->slug <br />";

    Hi there,
    Thank you for the response!

    Can you please tell me where I can put the code, so that I can get the results, but it won’t be visible to visitors of my blog site?

    Thank you.

    If you don’t need an actual list, you can add the ID column to the Admin->Posts->Categories screen just by installing the WP Show IDs plugin.

    Oh that is great! I just installed the plug-in, and it reveals all the category IDs. Perfect! Thank you! 🙂

    I kind of wanted to generate a list, but, with that plug-in, I can easily, and quickly, create my own list.

    If your problem has been solved, please use the dropdown on the right to mark this topic ‘Resolved’ so that anyone else with this question can see that there is a solution.

    Yes, I think that will do it.

    Thank you again!


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List categories by ID’ is closed to new replies.