WordPress Tutorials

How to Find Post, Category, Tag, Comments, or User ID in WordPress

As a WordPress user –using the script to run a blog or website – there comes a time when you need to quickly find a post, page, tag, category, comment or user ID to achieve a certain goal you may have in mind – like customizing how certain content is presented on your WordPress site’s frontend.

Instances When You May Need to Find a Post, Category, Tag, Comments or User ID

When you are using a plugin that allows you to customize what you display on your site to your visitors – through excluding or including certain design elements, theme features, content or premium plugin features.

Example 1: when you want to exclude certain popular blog posts from displaying on your blog by category, author, tag or any number of specific pages or posts.

Example 2: when you want to include or exclude certain theme or plugin features from certain pages or posts on your blog e.g. excluding social sharing buttons from your users My Accounts page (if you are using WooCommerce shopping cart to power your online store) or landing pages with download links you want readers to access only after they have signed up to your email list. This is mainly when you are using a WordPress Ecommerce Theme.

Example 3: when you want to easily show different types of content on your WordPress site sidebar depending on which post, page, tag or category a visitor to your site is viewing – either by entering IDs in a plugin’s settings page or via a combination of HTML, CSS, JavaScript and PHP code.

Example 4: when you want to deny some of your visitors or customers access to your site by banning them for security reasons, spamming reasons or violations of your site’s terms of use.

Example 5: when you want to use shortcodes that require any of these IDs in your post content or pages e.g. to show recent posts (or articles from a particular category) in one of your site’s popular pages – like your About, Archives, Start Here or Contact pages.

Why You Should Know How to Find IDs for Posts, Categories, Tags, Comments or Users in WordPress

The main reason is so that you are able to quickly achieve any of the aims mentioned above – excluding or including certain elements on your site depending on specific webpages being viewed by visitors to your site.

Main Areas to Focus on in Your WordPress Admin Dashboard to Find the IDs

The main areas to look at after logging into your WordPress admin are the menus on the left side – as shown by the arrows below – which are the Posts, Categories, Tags, Comments and Users section.

NOTE: The dashboard screenshot below was made after clicking the Posts menu in my admin area.

find-post-category-tag-comments-user-id

Now that you know the areas to focus on in your admin area, here’s how to find the IDs.

How to Find a Post ID in WordPress

Navigate to the posts area in your admin dashboard by clicking Posts on the left side of your screen – or append /wp-admin/edit.php at the end of your URL (where you installed WordPress e.g. www.example/wp-admin/edit.php) so that you can easily and quickly view posts published on your blog.

Now that you see a list of posts, to find the ID of a specific post, click the Edit link under that post’s title as shown below.

click-edit-post-find-ID

When you do this and look at your web browser’s address bar (I’m using Mozilla Firefox) you’ll see the part that looks like /wp-admin/post.php?post= followed by a number.

post id shown on web browser address bar

That number is the ID for that specific post. In this case, the post ID is 8766.

How to Find a Category ID in WordPress

To get the ID of a particular category in WordPress, navigate to the Categories area in your site’s admin area – under the Posts menu – as shown with the arrows in the first image in this post.

You can also view all post categories on your site by appending /wp-admin/edit-tags.php?taxonomy=category to your site’s URL (example.com/wp-admin/edit-tags.php?taxonomy=category).

find categories ID in admin area

And like we did with the post ID above, click Edit under a category title whose ID you want.

When you do this, you’ll see this /wp-admin/term.php?taxonomy=category&tag_ID= in your web browser’s address bar, followed by a number.

Locate Category ID

That number is the category ID you are looking for. In this case, the ID is 2.

How to Find a Tag ID in WordPress

Navigate to the tags area in your WordPress admin area by clicking Tags under the Posts menu as shown in the first image above – to see the post tags you have already added to your site. Or append this to your URL – where WordPress is installed – /wp-admin/edit-tags.php?taxonomy=post_tag.

Find tag ID

To check the ID of a tag click the Edit option under its title – and then check the number that is shown in your web browser’s address bar after the following: /wp-admin/term.php?taxonomy=post_tag&tag_ID=.

Locate Tag ID

In this case, the tag ID is 41.

How to Find Comment’s ID in WordPress

To do this, navigate to the Comments section of your WordPress admin area by clicking Comments on the left of your screen as shown below.

You can also append /wp-admin/edit-comments.php to your URL to view the comments on your site that are approved, waiting approval or those in the spam or trash folder.

Find Comment ID

To then check the ID of a comment, click the link that says Edit under the comment as shown in the screenshot above.

When you do this, here’s what you’ll see in your web browser’s address bar (image below).

Now look at the URL especially the part /wp-admin/comment.php?action=editcomment&c= followed by a number.

That number is the ID for that specific comment.

At the end of the part that says Permalink (followed by a direct URL to the comment) is also shown the same ID number pegged to this specific comment.

Here’s a screenshot of what I’m talking about.

comment ID shown in wordpress admin area

In our case, the comment ID is 16.

How to Find a User ID in WordPress

WordPress allows you to create users on your website or blog – and give them different levels of access to your site and roles (such as administrator, editor, author, contributor, subscriber, affiliate, shop manager, vendor, worker, accountant – depending on the features, plugins and themes you add to your site).

This is a great feature whether you are running a one-person blog, a multi-author blog, a forum (with bbPress), a social networking site (with BuddyPress), a viral content type site, an online store (with WooCommerce or Easy Digital Downloads – with or without an affiliates area), a marketplace, a membership site, a classifieds site, a portfolio site or business directory site on WordPress.

Owing to the number of users who may sign up for accounts on your site, you may want to get the ID of a specific user for the reasons we mentioned above.

To find a user ID, click Users on your admin area – as shown below – or append /wp-admin/users.php to your URL as we have done with previous examples.

Click Users Menu Item

When you do that you can now see the webpage with listings of users who currently have accounts on your site – and the user roles each have.

Locate the User Role

In the example above, the user Lloyd Mudis has the username Lloyd and his role is set to Editor. Another user John has his role set to Administrator.

To find an ID for a user (in this case Lloyd) click his username (or the Edit option under his username) as shown in the image above.

You’ll see the screen below. Check the address bar on your web browser and look at the number after the following string /wp-admin/user-edit.php?user_id=.

Locate User ID in Address bar

What is the number you see in the image above? 2.

That is Lloyd’s user’s ID. You can do this with any of the users listed above as well.

Make Your Search for Post ID, Category ID, Tag ID, Comment ID and User ID in WordPress Even Quicker

When you want to quickly get an ID, follow the methods shown above.

To move even faster, you can use the strings above and append them to your site’s URL to access sections of your admin area (like posts, categories, tags or users section) quickly.

Once you do this, instead of clicking the Edit option under the titles of blog posts, pages, users, tags, categories, or comments on your site, hover over the title and look at the bottom of your screen (in your web browser).

You’ll see the direct link WordPress will take you to when you click the title (of a post, tag, username or category).

When you look at it, you’ll see the part with the _id= (or editcomment&c= in the case of comments) followed by a number.

That number is the ID you are looking for. No need to click Edit – and wait for your browser to load another webpage before you can get what you want.

Also remember that if you have many tags, posts, pages, comments, users or categories on your site, you can always increase the number of items (post titles, comments, users, tags, pages, products or categories) shown to you on one page from the default 20 items to say even 990 by clicking the Screen Options menu on the top right of your screen on your WordPress admin (check the images above to see where it’s located), changing the number from 20 – by entering a number you want like 990 – and then clicking Apply to save the changes you make.

Edit Screen Options

Download
Download 3 WordPress themes & plugins​ with lifetime access for FREE!
x