One of the common questions I come across involves page IDs – specifically, how can a user tell what the page ID is for the current page they’re viewing? This is important for a lot of custom code jobs, so here are three quick and easy ways to find the Page ID in WordPress.
Method 1: Using the Built-In Editor
This is the fastest way if you want to stay in the WordPress administration without involving third party plugins.
First, we’ll navigate in our Administration section to find the page or post we’re looking for. Then, we click the “Edit” button:
Once that page loads, look at the top URL in your browser. You should see a string with something along the lines of
post=380&action=edit – that would mean you’re working with the item that is Post ID 380.
Method 2: Checking the Source Code
The first method works, but it can take more time than I like to spend. This way uses your browser’s built-in functionality, and just takes a little more comfort with code.
First, right click anywhere on the page you’re trying to find the Post ID for. Depending on the browser the dialogue may be different, but Chrome users should select “View Page Source”. This will display the HTML your site is using to display the content – scroll down until you find the
body tag. There, look through the CSS classes until you find one referencing the Post ID.
Method 3: Just add a plugin!
The absolute easiest way and the one that I always suggest is to just use one of the great, free plugins from the WordPress repository – Reveal IDs does the job, and you never have to worry about touching a bit of code. Neat!
Hopefully this helps those of you in need!
Have any questions or comments about this article, or ways you think it can be improved?
Join the conversation in the comments below, or sign up for my newsletter to recieve periodic updates!