How to find a page ID in WordPress

At some point in your blogging journey you might find yourself needing to identify the ID for your post or page. While there are plugins that can make the job slightly easier, finding the page ID without the help of such a tool isn’t hard to do.

Let’s find the post or page ID

There are two easy ways you can do this.

  1. Go to the Pages menu from your admin area and hover over the page you’re interested in:Find your page ID in WordPress
  2. Click to Edit your post or page and notice the ID in your browser’s URL bar. The ID is the number you’ll see there. Easy to find since it’s the only number.Locate your WordPress page ID

Why do I need to find the page or post ID?

Well, if you’re reading this article then most likely you already know why you need the page ID for. Still, most of the time you’re going to need the ID because you want to do some CSS tweaking on your WordPress-powered site.

I can further assume that you’ll be needing to find the class for your post or page in order to do the CSS tweaking. Luckily, that’s also an easy and standard text. Here is how it goes

  1. For pages it’s page-id-YOURPAGEIDHERE. So in my case it would be page-id-14. Don’t forget to prefix it with a dot for CSS use, like so .page-id-14
  2. For posts it’s postid-YOURPOSTIDHERE, which would mean postid-11. Again, add a dot to make it ready for CSS use, like .postid-11.

What can I actually do with the page ID?

You can target specific elements on just a single specific page or post.

Let’s say I want to change the body background color for one of my pages for whatever reason I might have. All I need to to is to add this in Additional CSS or in my child theme’s stylsheet: { background-color: red; }

Of course, the code above would have to be adjusted for your own case. Also, it’s worth noting that, depending on the theme you are using, it might work or not.

Subscribe for helpful tips and release info.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.