How to Find a WordPress Category ID: Complete Guide

English guide · Updated November 7, 2026

To find a WordPress category ID, open Posts → Categories, click the category name, and read the number after tag_ID= in your browser’s address bar. If the URL contains tag_ID=42, the category ID is 42. You do not need to install a plugin or edit any code.

This guide covers that quick method first, then shows how to look up IDs through the REST API, WP-CLI, PHP, and a read-only database query. It also explains product categories, parent categories, and what to check when the ID appears correct but a filter returns no posts. All domains, names, and IDs in the examples are illustrative.

What is a WordPress category ID?

A category is a term in WordPress’s category taxonomy. Its category ID is the numeric term_id assigned in that site’s database. A category’s name, slug, and ID identify different properties:

Property Example Meaning
Name Tutorials The readable label
Slug tutorials The URL-friendly identifier
Category ID 42 The numeric term identifier
Taxonomy category The kind of term
Parent 0 or another ID Zero means no parent category

term_taxonomy_id is a separate identifier for the term’s taxonomy record. If a plugin asks for a category ID, it usually wants term_id; confirm its documentation. Do not substitute a post ID, a menu item ID, or the number of posts in the category.

Reference: WordPress WP_Term properties.

Method 1: Find the category ID in the dashboard

  1. Sign in to your WordPress dashboard.
  2. Open Posts → Categories.
  3. Search for the category if the list is long.
  4. Click its name or the Edit link beneath it.
  5. Find tag_ID in the address bar and copy only its numeric value.
https://example.com/wp-admin/term.php?taxonomy=category&tag_ID=42&post_type=post

In this example, copy 42. The parameter is named tag_ID even for categories; taxonomy=category confirms the taxonomy. Do not click Delete or change any settings just to obtain the ID.

Find the ID without opening the editor

On a desktop browser, hover over the category’s name or Edit link. The browser’s link preview commonly shows the destination URL. Alternatively, right-click Edit, copy the link address, and read tag_ID from the copied URL. On a phone, opening the category editor is usually easier.

If Posts → Categories is missing, your account may lack permission to manage categories, or a plugin may customize the menu. Ask an administrator to check your access. Categories inside a post editor are selected by name, so the ID is generally unnecessary for ordinary publishing.

Reference: WordPress Categories screen.

Method 2: Find category IDs with the WordPress REST API

If the site exposes public category data, open this URL in your browser, replacing the domain and slug:

https://example.com/wp-json/wp/v2/categories?slug=tutorials&_fields=id,name,slug,parent

An illustrative response is:

[{"id":42,"name":"Tutorials","slug":"tutorials","parent":0}]

The id value is the category ID. For a broader list, use:

https://example.com/wp-json/wp/v2/categories?per_page=100&page=1&hide_empty=false&_fields=id,name,slug,parent,count

An empty array can mean that the slug does not exist or that filters restrict the result. A login requirement, 401, or 403 can reflect the site’s access policy. Public availability varies; do not assume that every site permits anonymous requests.

Reference: WordPress Categories REST endpoint.

Large lists and alternative REST URLs

Core collection requests accept at most 100 items per page. For a larger taxonomy, increase page and inspect the X-WP-TotalPages response header until you have read the available pages. A single request is not proof that you have every category.

If the pretty REST path fails, try the equivalent route below. If it also fails, use the dashboard method and investigate routing separately.

https://example.com/?rest_route=/wp/v2/categories&slug=tutorials&_fields=id,name,slug,parent

Reference: WordPress REST pagination.

Method 3: Find category IDs with WP-CLI

With authorized shell access and WP-CLI installed, run these read-only commands from the WordPress installation directory:

wp term list category --hide_empty=0 --fields=term_id,name,slug,parent,count
wp term get category tutorials --by=slug --field=term_id

The first command lists category IDs alongside their names and slugs, including empty categories. The second prints the ID for the exact tutorials slug. Replace that slug with your own.

Reference: wp term list.

Reference: wp term get.

For Multisite, add --url=https://example.com/subsite/ to target the intended site. For a different installation directory, use --path=/path/to/wordpress. Confirm the site before copying IDs: the same number on another site can refer to a different term.

Method 4: Retrieve category IDs with PHP

These examples require a loaded WordPress environment. They are for a suitable template, custom plugin, or controlled development environment; pasting PHP into the normal post editor will not execute it. Use a staging site when changing code. Create a backup before modifying site files.

Get the ID from a category slug

$category = get_category_by_slug( 'tutorials' );

if ( $category instanceof WP_Term ) {
    echo esc_html( (string) $category->term_id );
}

Check the returned object before reading term_id; the lookup can fail. A slug lookup also avoids confusion between the display name “Tutorials” and the slug tutorials.

Reference: get_category_by_slug().

Get the ID from a category name

$category_id = get_cat_ID( 'Tutorials' );

if ( $category_id > 0 ) {
    echo esc_html( (string) $category_id );
}

get_cat_ID() takes a name and returns 0 when no category is found. A successful lookup must return a positive ID before you use it in a filter.

Reference: get_cat_ID().

Get all categories assigned to the current post

$categories = get_the_category( get_the_ID() );

foreach ( $categories as $category ) {
    printf(
        '<p>%s: %d</p>',
        esc_html( $category->name ),
        (int) $category->term_id
    );
}

Use this inside the post loop, or pass a known post ID instead of get_the_ID(). A post can have several categories; choosing the first returned category does not establish an editorial “primary category.”

Reference: get_the_category().

Get the current category archive ID

if ( is_category() ) {
    $category_id = get_queried_object_id();
    echo esc_html( (string) $category_id );
}

The is_category() check matters: on a single post or another archive, the queried object is different.

Reference: get_queried_object_id().

List all categories, including empty ones

$categories = get_categories( array(
    'hide_empty' => false,
) );

foreach ( $categories as $category ) {
    printf(
        '<p>%s (%s): %d</p>',
        esc_html( $category->name ),
        esc_html( $category->slug ),
        (int) $category->term_id
    );
}

hide_empty is explicitly false so categories without published posts are included. Remove temporary diagnostic output after collecting the IDs.

Reference: get_categories().

Method 5: Check category IDs in the database

The dashboard is simpler for most users. If you already have authorized database access, the following SELECT-only query joins the term and taxonomy tables so that tags and product categories are not mixed into the result:

SELECT t.term_id, t.name, t.slug,
       tt.taxonomy, tt.term_taxonomy_id, tt.parent
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
    ON tt.term_id = t.term_id
WHERE tt.taxonomy = 'category'
ORDER BY t.name;

Replace wp_ with the actual table prefix; Multisite installations have site-specific tables. Read term_id for the category ID. Do not change numeric IDs directly: relationships and references can depend on them.

Reference: WordPress database tables.

WooCommerce product categories and custom taxonomies

Blog categories use category; WooCommerce product categories use product_cat. Open Products → Categories, edit the product category, and read tag_ID, checking that the URL contains taxonomy=product_cat.

In PHP, specify the taxonomy explicitly:

$term = get_term_by( 'slug', 'clothing', 'product_cat' );

if ( $term instanceof WP_Term ) {
    echo esc_html( (string) $term->term_id );
}

Reference: get_term_by().

WooCommerce also provides a public Store API for product categories, where enabled:

https://example.com/wp-json/wc/store/v1/products/categories?hide_empty=false&per_page=100

Read each object’s id. This differs from the authenticated WooCommerce management API under /wc/v3/. Never put management API secrets in a public page or share them to look up an ID.

Reference: WooCommerce Product Categories Store API.

For a custom taxonomy, replace product_cat with its registered taxonomy name. get_terms() can list its terms; the taxonomy must exist, and an invalid taxonomy can return WP_Error.

Reference: get_terms().

How to use a category ID correctly

Plugin filters, widgets, and shortcodes

Check the setting’s expected input. One plugin may accept 42, another a comma-separated list, and another a slug or dropdown selection. WordPress does not define a universal category shortcode or a universal category attribute. Use the plugin’s documented syntax.

Show posts from a category with WP_Query

$query = new WP_Query( array(
    'post_type'           => 'post',
    'post_status'         => 'publish',
    'posts_per_page'      => 5,
    'category__in'        => array( 42 ),
    'ignore_sticky_posts' => true,
) );

while ( $query->have_posts() ) {
    $query->the_post();
    printf(
        '<p><a href="%s">%s</a></p>',
        esc_url( get_permalink() ),
        esc_html( get_the_title() )
    );
}
wp_reset_postdata();

category__in matches the selected categories without automatically including their descendants. Use cat when you want its category-and-children behavior. For several IDs, category__in matches any selected category; category__and requires all of them; category__not_in excludes selected categories. Restore the original post data after a custom loop.

Reference: WP_Query category parameters.

Build a category link from its ID

$url = get_category_link( 42 );

if ( $url !== '' ) {
    echo '<a href="' . esc_url( $url ) . '">Tutorials</a>';
}

Generate the link through WordPress instead of assuming the archive always lives at /category/tutorials/. Permalink settings and category hierarchy can change that path.

Reference: get_category_link().

Filter posts through the REST API

https://example.com/wp-json/wp/v2/posts?categories=42&_fields=id,title,link

The categories parameter accepts category IDs. To exclude one, use categories_exclude=42. Public results normally reflect published posts available to the requester, so draft content will not appear simply because the ID is correct.

Reference: WordPress Posts REST endpoint.

Troubleshooting: the ID is correct, but it does not work

Symptom What to check
No posts appear Confirm the category has published posts, the correct post type is queried, and language or visibility filters are not narrowing the result.
Only child-category posts are missing Check whether the chosen query includes descendants; parent and child categories have different IDs.
The wrong category appears Verify both the site and taxonomy. A staging-site ID or product-category ID may be inappropriate.
Slug lookup returns nothing Copy the exact saved slug; do not substitute the display name or a translated slug.
A category is absent from a list Check pagination, search filters, and whether empty terms are hidden.
Changes seem ignored After confirming the saved setting, inspect page, object, and CDN caching as relevant.

To verify an ID independently, request /wp-json/wp/v2/categories/42 or run wp term get category 42, then compare the returned name and slug. If the lookup is correct, inspect the consuming plugin or query rather than guessing a different number.

Frequently asked questions

Do I need a plugin to see category IDs?

No. The edit URL is sufficient. An ID-column plugin can be convenient for frequent administration, but check its maintenance and compatibility before installing it.

Is tag_ID a tag ID or a category ID?

The parameter name is shared. Check the taxonomy beside it: category means a blog category, post_tag means a tag, and product_cat means a WooCommerce product category.

Can I find an ID without an admin account?

Sometimes, through publicly exposed REST data. If access is restricted, obtain authorized access or ask the site administrator.

Does renaming a category change its ID?

Editing the existing term’s name or slug normally preserves its ID. Deleting and recreating the category creates a new record; verify the ID again.

Will IDs stay the same after migration?

A full database copy commonly preserves them. Importing into another existing site can remap them. Verify destination IDs before relying on hardcoded filters.

Do parent and child categories share an ID?

No. Each category has its own term ID. The child’s parent field points to its parent’s ID; 0 denotes a top-level category.

Does the category ID affect SEO?

The number itself is an internal identifier, not a ranking tactic. Category organization, useful archives, and stable links deserve attention; changing IDs is unnecessary for that work.

Can I use a blog category ID for WooCommerce products?

Use a term from the taxonomy the feature expects. Standard product categories belong to product_cat, while blog categories belong to category.

Before you use the number

  1. Confirm the domain or Multisite subsite.
  2. Match the category name, slug, and taxonomy.
  3. Copy the numeric ID without the surrounding URL.
  4. Check whether the feature expects an ID, a slug, or a list.
  5. Verify the result with a known published post or product.