WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List categories by ID (7 posts)

  1. markross1967
    Member
    Posted 2 years ago #

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

    Thank you,
    Mark

  2. vtxyzzy
    Member
    Posted 1 year ago #

    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 />";
    }
  3. markross1967
    Member
    Posted 1 year ago #

    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.

  4. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  5. markross1967
    Member
    Posted 1 year ago #

    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.

  6. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  7. markross1967
    Member
    Posted 1 year ago #

    Yes, I think that will do it.

    Thank you again!

    Mark

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags