{"id":16808,"date":"2019-04-15T08:15:19","date_gmt":"2019-04-15T08:15:19","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=16808"},"modified":"2025-04-28T07:50:52","modified_gmt":"2025-04-28T07:50:52","slug":"wordpress-post-id","status":"publish","type":"post","link":"\/uk\/tutorials\/wordpress-post-id","title":{"rendered":"How to Find WordPress Post ID and Page ID"},"content":{"rendered":"<p>Every WordPress post or page has a unique number, called a post or page ID. It functions as an identifier for each piece of website content. Since WordPress CMS doesn&rsquo;t have a built-in feature to show post IDs, finding them can be tricky.<\/p><p>WordPress developers mainly use post and page IDs for website customization. If you&rsquo;re a beginner, you may wonder why you should use WordPress post IDs and how to use them.<\/p><p>This article is an all-in-one guide for WordPress post and page IDs. We&rsquo;ll explain the basics and why they are important.<\/p><p>\n\n\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-a-wordpress-post-id-and-page-id\">What Is a WordPress Post ID and Page ID?<\/h2><p>A post ID is a unique number assigned to each post on a WordPress website. Each page also contains an identifying number, called a page ID.<\/p><p>WordPress uses IDs to keep track of every piece of content within the <a href=\"\/uk\/tutorials\/wordpress-database\">WordPress database<\/a>. Other than posts and pages, there are IDs for media attachments, categories, and tags. These unique IDs will remain unchanged even if you rename or edit your posts and pages.<\/p><h2 class=\"wp-block-heading\" id=\"h-why-do-you-need-to-find-post-ids-and-page-ids\">Why Do You Need to Find Post IDs and Page IDs?<\/h2><p>You may need a post or page ID in several instances. For example, building a custom shortcode requires a unique ID number as the parameter. When adding widgets to a WordPress theme, you may also need to identify the post ID.<\/p><p>Here are some other cases where you can use a page ID or post ID:<\/p><ul class=\"wp-block-list\">\n<li>Creating custom post or page orders without interrupting other WordPress site content<\/li>\n\n\n\n<li>Including or excluding specific posts from a custom list<\/li>\n\n\n\n<li>Specifying a post or page in a custom template file<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-find-wordpress-post-ids-and-page-ids-manually-easy-methods\">How to Find WordPress Post IDs and Page IDs Manually: Easy Methods<\/h2><p>There are three simple ways to find WordPress page and post IDs:<\/p><ul class=\"wp-block-list\">\n<li>Via the site URL within the WordPress admin area<\/li>\n\n\n\n<li>Via the URL with the plain permalink<\/li>\n\n\n\n<li>Using the WordPress text editor<\/li>\n<\/ul><p>Let&rsquo;s go over the steps for each of these methods.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-via-the-url-within-the-wordpress-dashboard\">1. Via the URL Within the WordPress Dashboard<\/h3><p>Here&rsquo;s how to locate post, page, and category IDs within URLs from the WordPress admin dashboard.<\/p><p><strong>Post ID<\/strong><\/p><ol class=\"wp-block-list\">\n<li>From the WordPress dashboard, navigate to <strong>Posts<\/strong> -&gt; <strong>All Posts<\/strong>.<\/li>\n\n\n\n<li>Hover over one of your post titles. For example, we&rsquo;ll hover over a post entitled &ldquo;What Is HTML? Hypertext Markup Language Basics Explained&rdquo;.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\"><img decoding=\"async\" width=\"1024\" height=\"438\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-1024x438.png\" alt=\"WordPress Posts screen, highlighting a post entitled What Is HTML? Hypertext Markup Language Basics Explained\" class=\"wp-image-57881\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-1024x438.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-300x128.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-150x64.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-768x329.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22-1536x658.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png 1684w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>At the bottom left corner, a URL will appear. The post ID is the number between the &ldquo;<strong>post=<\/strong>&rdquo; and &ldquo;<strong>&amp;<\/strong>&rdquo; parameters.<\/li>\n<\/ol><p><strong>Page ID<\/strong><\/p><ol class=\"wp-block-list\">\n<li>Go to <strong>Pages<\/strong> -&gt; <strong>All Pages<\/strong>.<\/li>\n\n\n\n<li>Hover over a WordPress page title. For example, we&rsquo;ll choose the <strong>Home<\/strong> page.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\"><img decoding=\"async\" width=\"1024\" height=\"422\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-1024x422.png\" alt='WordPress Page screen, highlighting a page entitled \"Home\".' class=\"wp-image-57882\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-1024x422.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-300x124.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-150x62.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-768x317.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22-1536x633.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png 1683w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>At the bottom left corner, a URL will appear. The WordPress page ID is the number between the &ldquo;<strong>post=<\/strong>&rdquo; and &ldquo;<strong>&amp;<\/strong>&rdquo; parameters.<\/li>\n<\/ol><p><strong>Category ID<\/strong><\/p><ol class=\"wp-block-list\">\n<li>Navigate to <strong>Posts<\/strong> -&gt; <strong>Categories<\/strong>.<\/li>\n\n\n\n<li>Hover over a category.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\"><img decoding=\"async\" width=\"1024\" height=\"421\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22-1024x421.png\" alt=\"WordPress Categories screen, highlighting a category entitled Category\" class=\"wp-image-57883\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22-300x123.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22-150x62.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22-768x316.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>At the bottom left corner, a URL will appear. The category ID is the number between the &ldquo;<strong>category&amp;tag_ID=<\/strong>&rdquo; and &ldquo;<strong>&amp;<\/strong>&rdquo; parameters.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-2-via-the-url-with-the-plain-permalink-structure\">2. Via the URL With the Plain Permalink Structure<\/h3><p>If you <a href=\"https:\/\/wordpress.org\/support\/article\/using-permalinks\/\" target=\"_blank\" rel=\"noopener\">set the permalink structure<\/a> to the default or plain <a href=\"\/uk\/tutorials\/what-is-a-permalink\">permalink<\/a>, the &ldquo;<strong>post=<\/strong>&rdquo; parameter in the URL will change to &ldquo;<strong>p=<\/strong>&rdquo;. Meanwhile, the &ldquo;<strong>category&amp;tag_ID=<\/strong>&rdquo; parameter changes to &ldquo;<strong>cat=<\/strong>&rdquo; for the category ID and &ldquo;<strong>tag=<\/strong>&rdquo; for the tag ID.<\/p><p>Here&rsquo;s how to find a post ID in WordPress with the URL set to the plain permalink structure.<\/p><ol class=\"wp-block-list\">\n<li>From the WordPress admin dashboard, navigate to <strong>Settings<\/strong> -&gt; <strong>Permalinks<\/strong>.<\/li>\n\n\n\n<li>If you haven&rsquo;t set the permalink to plain, change it to <strong>Plain<\/strong> and click <strong>Save Changes<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\"><img decoding=\"async\" width=\"1024\" height=\"562\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-1024x562.png\" alt=\"WordPress Permalink Settings screen, highlighting the option Plain.\" class=\"wp-image-57884\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-1024x562.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-300x165.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-150x82.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-768x422.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain-1536x844.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png 1726w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Go to <strong>Posts<\/strong> -&gt; <strong>All Posts<\/strong>. Choose a post and click <strong>View<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\"><img decoding=\"async\" width=\"1024\" height=\"332\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-1024x332.png\" alt=\"WordPress Posts screen, highlighting the View button.\" class=\"wp-image-57885\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-1024x332.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-300x97.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-150x49.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-768x249.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button-1536x498.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png 1719w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>You will be taken to the website preview page. The post ID is the number following the &ldquo;<strong>p=<\/strong>&rdquo; parameter in the URL.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\"><img decoding=\"async\" width=\"1024\" height=\"37\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-1024x37.png\" alt=\"Web browser's address bar, highlighting a post ID.\" class=\"wp-image-57886\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-1024x37.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-300x11.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-150x5.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-768x28.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID-1536x56.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png 1919w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-3-using-the-wordpress-text-editor\">3. Using the WordPress Text Editor<\/h3><p>You can also find WordPress post IDs using the WordPress text editor.<\/p><ol class=\"wp-block-list\">\n<li>Navigate to <strong>Posts<\/strong> -&gt; <strong>All Posts<\/strong>. To identify a WordPress page ID, navigate to <strong>Pages<\/strong> -&gt; <strong>All<\/strong> <strong>Pages<\/strong> instead.<\/li>\n\n\n\n<li>Choose a post or page and click <strong>Edit<\/strong> to open the WordPress text editor.<\/li>\n\n\n\n<li>For example, we used a post entitled &ldquo;<a href=\"\/uk\/tutorials\/how-to-make-a-website\">How to Make a Website From Scratch: A Beginner&rsquo;s Guide<\/a>&rdquo;.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\"><img decoding=\"async\" width=\"1024\" height=\"328\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-1024x328.png\" alt=\"WordPress Posts screen, highlighting the Edit button.\" class=\"wp-image-57887\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-1024x328.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-300x96.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-150x48.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-768x246.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button-1536x492.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png 1720w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Locate the post ID number in the address bar. It&rsquo;s in the URL, located between the &ldquo;<strong>post=<\/strong>&rdquo; and &ldquo;<strong>&amp;<\/strong>&rdquo; parameters.<\/li>\n<\/ol><h2 class=\"wp-block-heading\" id=\"h-how-to-find-a-wordpress-post-id-or-page-id-with-a-plugin\">How to Find a WordPress Post ID or Page ID With a Plugin<\/h2><p>You can use a WordPress plugin to find post and page IDs. Since there are many WordPress plugins to choose from, we recommend <a href=\"https:\/\/wordpress.org\/plugins\/reveal-ids-for-wp-admin-25\/\" target=\"_blank\" rel=\"noopener\">Reveal IDs<\/a>.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\"><img decoding=\"async\" width=\"1024\" height=\"694\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page-1024x694.png\" alt='The Reveals IDs official website, inside the \"WordPress\" page.' class=\"wp-image-57888\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page-300x203.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page-150x102.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page-768x520.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p><strong>Reveal IDs Stats<\/strong>:<\/p><ul class=\"wp-block-list\">\n<li><strong>Downloads:<\/strong> 60,000+<\/li>\n\n\n\n<li><strong>Rating:<\/strong> 5\/5<\/li>\n\n\n\n<li><strong>Notable features:<\/strong> sortable columns, lightweight, and multilingual support<\/li>\n\n\n\n<li><strong>Best suited for:<\/strong> advanced WordPress users or developers<\/li>\n\n\n\n<li><strong>Price:<\/strong> free<\/li>\n<\/ul><p>Reveal IDs is a WordPress plugin that lets you see WordPress IDs for posts, pages, categories, and tags within the admin page. This free plugin is lightweight, multilingual, and regularly updated.<\/p><p>After <a href=\"\/uk\/tutorials\/wordpress\/how-to-install-wordpress-plugins\">installing the WordPress plugin<\/a>, navigate to <strong>Posts <\/strong>-&gt;<strong> All Posts<\/strong> or <strong>Pages <\/strong>-&gt;<strong> All Pages<\/strong> from your WordPress dashboard. You will see a new column of post or page IDs.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\"><img decoding=\"async\" width=\"1024\" height=\"356\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1024x356.png\" alt=\"WordPress Posts screen, highlighting a post ID column.\" class=\"wp-image-57889\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1024x356.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-300x104.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-150x52.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-768x267.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1536x534.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png 1720w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"h-how-to-find-wordpress-post-ids-and-page-ids-advanced-methods\">How to Find WordPress Post IDs and Page IDs: Advanced Methods<\/h2><p>Check out the following methods for more technical ways to retrieve post and page IDs.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-using-wordpress-functions\">1. Using WordPress Functions<\/h3><p>There are four ways of getting post IDs using WordPress functions.<\/p><p><strong>Get Post ID Using the get_the_ID() and the_ID() Functions<\/strong><\/p><p>The <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_id\/\" target=\"_blank\" rel=\"noopener\">get_the_ID()<\/a> and <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/the_id\/\" target=\"_blank\" rel=\"noopener\">the_ID()<\/a> functions display the current post&rsquo;s ID. The main difference between the two functions is that <strong>get_the_ID()<\/strong> returns the post ID without displaying it, while <strong>the_ID() <\/strong>always prints the post ID.<\/p><p>If you use the <strong>get_the_ID() <\/strong>function, make sure to add the <strong>echo<\/strong> function to display post IDs:<\/p><pre class=\"wp-block-preformatted\">echo get_the_id();<\/pre><p>Meanwhile, <strong>the_ID()<\/strong> doesn&rsquo;t need the <strong>echo<\/strong> function to view post IDs:<\/p><pre class=\"wp-block-preformatted\">the_ID();<\/pre><p><strong>Get Post ID by Title<\/strong><\/p><p>The <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_page_by_title\/\" target=\"_blank\" rel=\"noopener\">get_page_by_title()<\/a> function works for WordPress pages and custom post types. This function can be applied to the theme or plugin files.<\/p><p>Here is how the <strong>get_page_by_title()<\/strong> function looks like:<\/p><pre class=\"wp-block-preformatted\">$mypost = get_page_by_title( 'post title here', '', 'post' );\necho $mypost-&gt;ID;<\/pre><p>Make sure to change the &lsquo;<strong>post title here<\/strong>&lsquo; parameter with your post title.<\/p><p><strong>Get Post ID by URL<\/strong><\/p><p>You can also fetch post IDs from WordPress URLs using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/url_to_postid\/\" target=\"_blank\" rel=\"noopener\">url_to_postid()<\/a> function. This function examines a URL and determines its post ID.<\/p><p>To use the <strong>url_to_postid()<\/strong> function, enter the post URL into the function like this:<\/p><pre class=\"wp-block-preformatted\">url_to_postid( 'post&rsquo;s URL here');<\/pre><p>Change the &lsquo;<strong>post&rsquo;s URL here<\/strong>&lsquo; parameter with the post&rsquo;s URL.<\/p><p><strong>Get Post ID by Slug<\/strong><\/p><p>Another way to retrieve WordPress post IDs is by using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_page_by_path\/\" target=\"_blank\" rel=\"noopener\">get_page_by_path()<\/a> function. This function is similar to the <strong>get_page_by_title()<\/strong> function. However, instead of using the post title, you need to enter the post&rsquo;s slug or path:<\/p><pre class=\"wp-block-preformatted\">$mypost = get_page_by_path('slug here', '', 'post');\necho $mypost-&gt;ID;<\/pre><p>Remember to replace &lsquo;<strong>slug here<\/strong>&lsquo; with your own post slug.<\/p><p>We recommend backing up your WordPress site before testing these functions. We will show you how to use the <strong>get_the_ID()<\/strong> function:<\/p><ol class=\"wp-block-list\">\n<li>From the WordPress dashboard, navigate to <strong>Appearance<\/strong> -&gt; <strong>Theme File Editor<\/strong>.<\/li>\n\n\n\n<li>Go to the <strong>Theme Files<\/strong> tab -&gt; <strong>template-parts<\/strong> -&gt; <strong>content.php<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\"><img decoding=\"async\" width=\"1024\" height=\"542\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-1024x542.png\" alt=\"WordPress Theme Editor screen, highlighting the content.php file.\" class=\"wp-image-57890\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-1024x542.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-300x159.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-150x79.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-768x406.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file-1536x813.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png 1703w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Enter the <strong>get_the_ID()<\/strong> function under the comment tag.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\"><img decoding=\"async\" width=\"1024\" height=\"568\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-1024x568.png\" alt=\"WordPress Theme Editor Screen, highlighting a code snippet\" class=\"wp-image-57891\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-1024x568.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-300x166.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-150x83.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-768x426.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet-1536x852.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png 1663w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Click <strong>Update File<\/strong> to save the changes.<\/li>\n\n\n\n<li>Click the <strong>Visit Site<\/strong> button in the top left corner of the screen. You will see the post ID at the top of each post&rsquo;s title.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\"><img decoding=\"async\" width=\"1024\" height=\"561\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-1024x561.png\" alt=\"A website's homepage, highlighting two Post IDs.\" class=\"wp-image-57892\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-1024x561.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-300x164.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-150x82.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-768x421.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs-1536x841.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png 1902w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-2-using-the-wordpress-posts-table-with-custom-code\">2. Using the WordPress Posts Table With Custom Code<\/h3><p>You can add a post ID column in the WordPress posts table using a custom code. This is an excellent method if you regularly use post IDs:<\/p><ol class=\"wp-block-list\">\n<li>Open <strong>File Manager<\/strong> from your hosting control panel. Alternatively, use a <a href=\"\/uk\/tutorials\/wordpress-file-manager\">file manager plugin<\/a> or a <a href=\"\/uk\/tutorials\/wordpress-theme-editor\/\">theme editor<\/a> to access website files within the WordPress dashboard.<\/li>\n\n\n\n<li>In File Manager, navigate to <strong>public_html <\/strong>-&gt; <strong>wp-content<\/strong> -&gt; <strong>themes<\/strong>.<\/li>\n\n\n\n<li>Open your active WordPress theme directory. For instance, the active theme is <strong>Twenty Sixteen<\/strong>. Consider creating a <a href=\"\/uk\/tutorials\/how-to-create-wordpress-child-theme\">child theme<\/a> to minimize the risk of breaking the original theme&rsquo;s functionality.<\/li>\n\n\n\n<li>Open your <a href=\"\/uk\/tutorials\/functions-php-wordpress\">theme&rsquo;s functions.php file<\/a> with a text editor.<\/li>\n\n\n\n<li>Copy and paste the following code snippet at the bottom line of the <strong>functions.php<\/strong> file:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">function add_column( $columns ){\n\t$columns['post_id_clmn'] = 'ID'; \/\/ $columns['Column ID'] = 'Column Title';\n\treturn $columns;\n}\nadd_filter('manage_posts_columns', 'add_column', 5);\n\nfunction column_content( $column, $id ){\n\tif( $column === 'post_id_clmn')\n\t\techo $id;\n}\nadd_action('manage_posts_custom_column', 'column_content', 5, 2);\n<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\"><img decoding=\"async\" width=\"1024\" height=\"629\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets-1024x629.png\" alt=\"hPanel File Manager's built-in text editor, highlighting code snippets.\" class=\"wp-image-57893\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets-1024x629.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets-300x184.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets-150x92.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets-768x472.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png 1123w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"6\" class=\"wp-block-list\">\n<li>Click <strong>Save &amp; Close<\/strong>.<\/li>\n\n\n\n<li>Access your WordPress dashboard and navigate to <strong>Posts<\/strong> -&gt; <strong>All Post<\/strong>. You will see a new column containing the posts&rsquo; ID numbers.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\"><img decoding=\"async\" width=\"1024\" height=\"356\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-1024x356.png\" alt=\"WordPress Posts screen, highlighting a post ID column.\" class=\"wp-image-57894\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-1024x356.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-300x104.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-150x52.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-768x267.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1-1536x534.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png 1720w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-3-via-the-wordpress-database\">3. Via the WordPress Database<\/h3><p>The database stores all necessary WordPress website data, including the IDs of posts, pages, categories, tags, and comments.<\/p><p>To find post IDs within the site&rsquo;s database, follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>From your hosting control panel, navigate to <strong>Databases <\/strong>-&gt;<strong> phpMyAdmin<\/strong>.<\/li>\n\n\n\n<li>Choose a database from the list of current databases and click <strong>Enter phpMyAdmin<\/strong>.<\/li>\n\n\n\n<li>In phpMyAdmin, go to <strong>wp_posts<\/strong>. Then, locate the <strong>ID column<\/strong> on the <strong>wp_posts<\/strong> table to see the post IDs.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\"><img decoding=\"async\" width=\"1024\" height=\"695\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column-1024x695.png\" alt=\"wp_post table inside phpMyAdmin, highlighting a post ID column.\" class=\"wp-image-57895\" style=\"width:840px;height:570px\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column-1024x695.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column-300x204.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column-150x102.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column-768x521.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png 1483w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-4-using-the-wp-query-loop\">4. Using the WP_Query Loop<\/h3><p><a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/\" target=\"_blank\" rel=\"noopener\">WP_Query<\/a> is a PHP class in WordPress that lets you load content from the WordPress database. Developers use it to build custom content lists &ndash; for example, to display specific posts or pages on the site&rsquo;s front-end.<\/p><p>To display post IDs using the WP_Query loop, use the following code:<\/p><pre class=\"wp-block-preformatted\">$id_query = new WP_Query( &lsquo;posts_per_page=6&rsquo; );\n\nwhile( $id_query-have_posts() ) : $id_query-&gt;the_post();\n\t$id_query-&gt;post-&gt;ID;\nendwhile;<\/pre><h3 class=\"wp-block-heading\" id=\"h-5-using-the-global-post-variable\">5. Using the global $post Variable<\/h3><p>Getting post IDs using the<strong> global $post <\/strong>variable is similar to using the <strong>get_the_ID()<\/strong> function. The difference is that the <strong>global $post <\/strong>variable is used inside a PHP function. Take a look at the following code:<\/p><pre class=\"wp-block-preformatted\">global $post;\necho $post-&gt;ID;<\/pre><p>Follow these steps to view the post IDs of all the posts:<\/p><ol class=\"wp-block-list\">\n<li>Access the WordPress dashboard and navigate to <strong>Appearance<\/strong> -&gt; <strong>Theme File Editor<\/strong>.<\/li>\n\n\n\n<li>Go to the <strong>Theme Files<\/strong> tab -&gt; <strong>single.php<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\"><img decoding=\"async\" width=\"1024\" height=\"611\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-1024x611.png\" alt=\"WordPress Theme Editor, highlighting the single.php file\" class=\"wp-image-57896\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-1024x611.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-300x179.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-150x90.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-768x458.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file-1536x917.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png 1660w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Enter the <strong>global $post<\/strong> variable inside the <strong>single.php<\/strong> file. The variable is located under the <a href=\"\/uk\/tutorials\/get_template_part\"><strong>get_template_part()<\/strong> function<\/a>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\"><img decoding=\"async\" width=\"1024\" height=\"612\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-1024x612.png\" alt=\"WordPress Theme Editor, highlighting code snippets.\" class=\"wp-image-57897\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-1024x612.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-300x179.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-150x90.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-768x459.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets-1536x918.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png 1659w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Click <strong>Update File<\/strong> to save the changes.<\/li>\n\n\n\n<li>Go to <strong>Posts<\/strong> -&gt; <strong>All Posts<\/strong>. In the <strong>Posts<\/strong> screen, select a post and click <strong>View<\/strong>. You will see the current post ID at the bottom of the page.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"\/uk\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\"><img decoding=\"async\" width=\"1024\" height=\"546\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID-1024x546.png\" alt=\"A website's post, highlighting a post ID.\" class=\"wp-image-57898\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-post-highlighting-a-post-ID.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-post-highlighting-a-post-ID-300x160.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-post-highlighting-a-post-ID-150x80.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-post-highlighting-a-post-ID-768x410.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2019\/04\/A-websites-post-highlighting-a-post-ID-1536x820.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-6-through-the-global-wpdb-variable\">6. Through the global $wpdb Variable<\/h3><p>You can use the<strong> global $wpdb<\/strong> variable in a function to get post IDs. In this section, we will cover three ways of using this variable.<\/p><p><strong>Retrieve Post IDs by Meta Key<\/strong><\/p><p>The <strong>global $wpdb<\/strong> variable can fetch a post ID by its meta key. You need to use either an SQL query or a WP_Query query to achieve this.<\/p><p>Take a look at the following code:<\/p><pre class=\"wp-block-preformatted\">\/*\n * Returns matched post IDs for a meta key from the database\n *\n * @param string $meta_key\n *\n * @return array Array of post IDs - if more than one post matched has this meta key\n * @return int Post ID - if just one post found\n *\/\nfunction post_id_by_meta_key( $meta_key ){\n\tglobal $wpdb;\n\n\t$ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( \"SELECT post_id FROM $wpdb-&gt;postmeta WHERE meta_key = %s\", $meta_key ) );\n \techo $post-&gt;post_id;\n\n\tif( count( $ids ) &gt; 1 ) \n\t\treturn $ids; \/\/ return array\n\telse\n\t\treturn $ids[0]; \/\/ return int\n}<\/pre><p><strong>Retrieve Post IDs by Meta Key and Value<\/strong><\/p><p>Similar to the previous meta key function, but you can also specify a meta value. Here&rsquo;s what the meta key and value function looks like:<\/p><pre class=\"wp-block-preformatted\">\/*\n * Returns matched post IDs for a pair of meta key and meta value from the database\n *\n * @param string $meta_key\n * @param mixed $meta_value\n *\n * @return array|int Post ID(s)\n *\/\nfunction post_id_by_meta_key_and_value( $meta_key, $meta_value ){\n\tglobal $wpdb;\n\t$ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( \"SELECT post_id FROM $wpdb-&gt;postmeta WHERE meta_key = %s AND meta_value = %s\", $meta_key, $meta_value ) );\n\techo $post-&gt;post_id;\n \n\tif( count( $ids ) &gt; 1 ) \n\t\treturn $ids; \/\/ return array\n\telse\n\t\treturn $ids[0]; \/\/ return int\n}<\/pre><p><strong>Retrieve Post IDs by Term ID<\/strong><\/p><p>You can also use the<strong> global $wpdb<\/strong> variable to find a category or tag ID. The following is an example of the term ID function:<\/p><pre class=\"wp-block-preformatted\">\/*\n * Returns post IDs in a term with a given ID\n *\n * @param int $term_id\n *\n * @return array|int Post ID(s)\n *\/\nfunction post_id_by_term_id( $term_id ){\n\tglobal $wpdb;\n$ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( \"SELECT object_id FROM $wpdb-&gt;term_relationships WHERE term_taxonomy_id = %d\", $term_id ) );\n\t\nif( count( $ids ) &gt; 1 ) \n\t\treturn $ids; \/\/ return array\n\telse\n\t\treturn $ids[0]; \/\/ return int\n}\n<\/pre><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>WordPress post and page IDs can help you perform advanced website customizations, such as excluding or including a specific post, creating a custom code, or editing a theme.<\/p><p>There are several ways of finding post IDs and page IDs. Here&rsquo;s a recap of beginner-friendly ways to get post IDs:<\/p><ul class=\"wp-block-list\">\n<li>Via the URL within the WordPress dashboard<\/li>\n\n\n\n<li>Via the URL with the plain permalink structure<\/li>\n\n\n\n<li>Using the WordPress editor<\/li>\n\n\n\n<li>Using a WordPress plugin<\/li>\n<\/ul><p>As for the more advanced methods, here&rsquo;s a recap:<\/p><ul class=\"wp-block-list\">\n<li>Using WordPress functions<\/li>\n\n\n\n<li>Using the WordPress posts table with custom code<\/li>\n\n\n\n<li>Via the WordPress database<\/li>\n\n\n\n<li>Using the WP_Query loop<\/li>\n\n\n\n<li>Using the global $post variable<\/li>\n\n\n\n<li>Using the global $wpdb variable<\/li>\n<\/ul><p>Keep in mind that editing WordPress files requires a good understanding of the PHP scripting language. We also recommend backing up your WordPress website before performing any of the more advanced methods.<\/p><p>We hope this article has helped you understand how to find post IDs and page IDs in WordPress. If you have any questions or tips of your own related to the topic, feel free to leave a comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every WordPress post or page has a unique number, called a post or page ID. It functions as an identifier for each piece of website content. Since WordPress CMS doesn&rsquo;t have a built-in feature to show post IDs, finding them can be tricky. WordPress developers mainly use post and page IDs for website customization. If [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/wordpress-post-id\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":258,"featured_media":71566,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"WordPress Post ID: What It Is + How to Find It","rank_math_description":"Don't know how to find post ID in WordPress? No worries! In this article you will learn all about WordPress post IDs and how to find it.","rank_math_focus_keyword":"wordpress post id","footnotes":""},"categories":[22639,22633],"tags":[],"class_list":["post-16808","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advanced","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/wordpress-post-id","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/post-id-wordpress","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/wordpress-post-id","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/wordpress-post-id","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/wordpress-post-id","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/post-id-wordpress","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/wordpress-post-id","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/wordpress-post-id","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/wordpress-post-id","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/wordpress-post-id","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/16808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/258"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=16808"}],"version-history":[{"count":25,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/16808\/revisions"}],"predecessor-version":[{"id":126527,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/16808\/revisions\/126527"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media\/71566"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=16808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=16808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=16808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}