Sooner or later, you face the need to find a WordPress page ID. Every post and page has a unique number. This indicator helps to find a page or a publication in a matter of seconds.
It comes in handy when you set up a blog or make program operations. While setting up some plugins, the ID will specify which page the plugin must take up a residence.
WordPress doesn’t generate page or post IDs in an admin panel, but finding them is not a big deal.
In this article, you will familiarize with six ways to detect a number of the post, category, and page, which are as simple as using WordPress. Let’s go!
URL of the page already has a WordPress page ID.
Go to a console > Pages. In the list, find a specific page. In the edit screen, look at the URL that contains the number.
About Our Team ID – 61.
Likewise, you can find a category ID. Go to console, open a list with posts, categories or tags, open an edit screen, and pick up a number from URL.
Category ID here is 1.
In the console, you can also find an ID for media applicable for creating a Gallery shortcode; for example:
Although it’s easy to find page ID in WordPress console, it still can seem tricky, especially when you work with IDs on a regular basis. So, here is a super light plugin that adds IDs of:
It won’t affect the website’s performance because it has a tiny 100-lines code and has no- front-end requirements that slow down the work of the website.
In a console, it looks like this:
If you don’t need the column anymore, open Screen Options and uncheck an ID box.
In simple words, PHPMyAdmin is a place on your hosting, where you can manage the database of your website.
You can access a PHP-based frontend control panel in your browser or download it to your computer. If you hadn’t done it yet, there is a detailed guideline on how to install it. This tool comes in handy when you need to manage MySQL, work with a database, backups, searches, etc..
So, open a frontend control panel > wp_posts. In a table, you will find IDs for all posts.
Keep on reading if you have some basic PHP understanding. In this case, you can find a WordPress page ID in an object of the post. If we don’t know an ID of the post, we will use a global post object—a page or post, which you currently browse or the one that is used in a cycle:
In this window, you will view the code of the post.
This CMS has an incredible function that helps to find a WordPress page ID by its title – get_page_by_title(). Don’t be confused with its name—it also works with all types of posts.
Instead of using the function mentioned previously, you can find the post object properties using WP_Query or its alternative loops:
There were fast and easy ways to find page ID in WordPress. Now, let’s move to other important issues.
In this case, a page or a post ID finder would also come in handy. You already know about Show IDs by 99 Robots, but here is an alternative—Reveal IDs.
Its working principle is the same as with the previous plugin—you install it and it displays all IDs of the pages, posts, categories, tags, and media.
Using such plugins will save a lot of time because you don’t search for each ID manually.
Also, when you open an edit mode, instead of opening the page just hover a mouse on the page name. You will see a status bar below, where you will see a post ID. This way you can find several post IDs in a matter of minutes.
Most of the ways mentioned previously are also applicable for finding a WordPress category ID. You can find it in a WordPress console as described at the first point or use one of the plugins.
You can also do it manually as described in the previous paragraph. Open an edit mode of the categories in a WordPress console and just hover a mouse on the category name. Below you will also see a status bar with a WordPress category ID.
In the URL, always look for tag_ID=X where X is a category ID.
The most common way to get permalink by ID is to use this function:
get_permalink( int|WP_Post $post, bool $leavename = false )
In this article, you will find more information about the function and its usage. Its task lies in:
It can be used out of the WordPress cycle (for this purpose, use the first parameter $id—ID of the post, whose link you want to get.
If you don’t specify the ID parameter and use a function out of the WordPress cycle on the archive pages (categories, data-based archives, author-based archives, etc.), the function will return the link to the recent post in the cycle of the current page but not the link of the current page.
Here are a couple of samples.
Let’s get the link to a current post (within WordPress cycle). The function doesn’t display the data itself. So, you need to use PHP inquiry echo:
Permanent link to the post:
<?php echo get_permalink(); ?>
Let’s get links to certain posts. You need to display a list where you will get links to pages with ID 1 to ID 10. Information about a blog:
<ul> <li><a href="<?php echo get_permalink(1); ?>">About blog </a></li> <li><a href="<?php echo get_permalink(10); ?>">About author</a></li> </ul>
Using a second parameter. Let the %postname% tag remain unchanged. If there is a %post_id%/%postname% structure in the SEF, the function will work this way:
<?php echo get_permalink(185, true ); ?>
will display: http://example.com/185/%postname%
All publications that you create in WordPress are stored not in a form of the separate files but in a database. When a user types the address of the website in a browser, a server activates PHP code that reads the data out of a database. Meanwhile, a page is being filled in with information within seconds.
With cash plugins on the website, the pages can be downloaded from the cash of a server or a browser while there are follow-up visits (meaning there is a separate HTML file for every regularly updated page), but all changes are still made in an admin dashboard. A page is displayed on the website just like any other post. The only difference is that it doesn’t have the date of publication, comments, and social buttons.
To get information about the pages, go to phpMyAdmin with the data given by a hosting provider during registration.
Choose the database (1) > wp_posts folder (2).
On the right, there is information about posts and publications:
For some pages, you might find “revision” categories. They are often created automatically and are useless. To save the space in the database, you can erase those revisions. If there are too many revisions to delete, got to SQL and type the following inquiry in the box of the SQL inquiries:
DELETE FROM wp_posts WHERE post_type = "revision";
All revisions will be deleted.
Remember to create database backup while working with it. One wrong inquiry can screw up a month’s work. For instance, if you don’t specify the type of the post as “revision” in the previous inquiry, all publications will disappear from the website.
To wrap up it’s important to say that working with WordPress page ID, as well as IDs for posts, categories, tags, and media libraries, seems tricky but isn’t that complicated. Hopefully, the methods in this article will help you to deal with the task fast. If you have any questions, don’t hesitate to ask them in the comments.
Keep up with the blog for more guidelines!
Subscribe to our newsletter and access exclusive content and offers available only to MonsterPost subscribers.