{"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-05-26T08:14:52","modified_gmt":"2025-05-26T08:14:52","slug":"wordpress-post-id","status":"publish","type":"post","link":"\/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 an ID. It functions as an identifier for each piece of website content. Since the WordPress content management system (CMS) doesn&rsquo;t have a built-in feature to show post and page 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 know about WordPress post or page 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-are-wordpress-post-ids-and-page-ids\">What are WordPress post IDs and page IDs?<\/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=\"\/tutorials\/wordpress-database\">WordPress database<\/a>. Other than posts and pages, there are IDs for media attachments, categories, and tags. These unique IDs remain unchanged even if you rename or edit your posts and pages.<\/p><h2 class=\"wp-block-heading\" id=\"h-why-would-you-need-to-find-post-ids-or-page-ids\">Why would you need to find post IDs or 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-and-page-ids-manually\">How to find WordPress post and page IDs manually<\/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-in-the-wordpress-dashboard\">1. Via the URL in 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=\"\/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=\"1684\" height=\"721\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/public\" alt=\"WordPress Posts screen, highlighting a post entitled What Is HTML? Hypertext Markup Language Basics Explained\" class=\"wp-image-57881\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=1684,fit=scale-down 1684w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-entitled-22What-Is-HTML-Hypertext-Markup-Language-Basics-Explained22.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1684px) 100vw, 1684px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\"><img decoding=\"async\" width=\"1683\" height=\"694\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/public\" alt='WordPress Page screen, highlighting a page entitled \"Home\".' class=\"wp-image-57882\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=1683,fit=scale-down 1683w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Page-screen-highlighting-a-page-entitled-22Home22.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1683px) 100vw, 1683px\" \/><\/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=\"\/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=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\/public\" alt=\"WordPress Categories screen, highlighting a category entitled Category\" class=\"wp-image-57883\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Categories-screen-highlighting-a-category-entitled-22Category22.png\/w=768,fit=scale-down 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-a-url-with-a-plain-permalink-structure\">2. Via a URL with a 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 a default or plain <a href=\"\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\"><img decoding=\"async\" width=\"1726\" height=\"948\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/public\" alt=\"WordPress Permalink Settings screen, highlighting the option Plain.\" class=\"wp-image-57884\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=1726,fit=scale-down 1726w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Permalink-Settings-screen-highlighting-the-option-Plain.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1726px) 100vw, 1726px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\"><img decoding=\"async\" width=\"1719\" height=\"557\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/public\" alt=\"WordPress Posts screen, highlighting the View button.\" class=\"wp-image-57885\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=1719,fit=scale-down 1719w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-View-button.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1719px) 100vw, 1719px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\"><img decoding=\"async\" width=\"1919\" height=\"70\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/public\" alt=\"Web browser's address bar, highlighting a post ID.\" class=\"wp-image-57886\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=1919,fit=scale-down 1919w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/Web-browsers-address-bar-highlighting-a-post-ID.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1919px) 100vw, 1919px\" \/><\/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=\"\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\"><img decoding=\"async\" width=\"1720\" height=\"551\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/public\" alt=\"WordPress Posts screen, highlighting the Edit button.\" class=\"wp-image-57887\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=1720,fit=scale-down 1720w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-the-Edit-button.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1720px) 100vw, 1720px\" \/><\/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=\"\/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=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\/public\" alt='The Reveals IDs official website, inside the \"WordPress\" page.' class=\"wp-image-57888\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/The-Reveals-IDs-official-website-inside-the-22WordPress22-page.png\/w=768,fit=scale-down 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=\"\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\"><img decoding=\"async\" width=\"1720\" height=\"598\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/public\" alt=\"WordPress Posts screen, highlighting a post ID column.\" class=\"wp-image-57889\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=1720,fit=scale-down 1720w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1720px) 100vw, 1720px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\"><img decoding=\"async\" width=\"1703\" height=\"901\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/public\" alt=\"WordPress Theme Editor screen, highlighting the content.php file.\" class=\"wp-image-57890\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=1703,fit=scale-down 1703w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-screen-highlighting-the-content.php-file.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1703px) 100vw, 1703px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\"><img decoding=\"async\" width=\"1663\" height=\"922\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/public\" alt=\"WordPress Theme Editor Screen, highlighting a code snippet\" class=\"wp-image-57891\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=1663,fit=scale-down 1663w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-Screen-highlighting-a-code-snippet.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1663px) 100vw, 1663px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\"><img decoding=\"async\" width=\"1902\" height=\"1042\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/public\" alt=\"A website's homepage, highlighting two Post IDs.\" class=\"wp-image-57892\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=1902,fit=scale-down 1902w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-homepage-highlighting-two-Post-IDs.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1902px) 100vw, 1902px\" \/><\/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=\"\/tutorials\/wordpress-file-manager\">file manager plugin<\/a> or a <a href=\"\/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=\"\/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=\"\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\"><img decoding=\"async\" width=\"1123\" height=\"690\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/public\" alt=\"hPanel File Manager's built-in text editor, highlighting code snippets.\" class=\"wp-image-57893\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/w=1123,fit=scale-down 1123w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/hPanel-File-Managers-built-in-text-editor-highlighting-code-snippets.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1123px) 100vw, 1123px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\"><img decoding=\"async\" width=\"1720\" height=\"598\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/public\" alt=\"WordPress Posts screen, highlighting a post ID column.\" class=\"wp-image-57894\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=1720,fit=scale-down 1720w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Posts-screen-highlighting-a-post-ID-column-1.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1720px) 100vw, 1720px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\"><img decoding=\"async\" width=\"1483\" height=\"1006\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/public\" alt=\"wp_post table inside phpMyAdmin, highlighting a post ID column.\" class=\"wp-image-57895\" style=\"width:840px;height:570px\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/w=1483,fit=scale-down 1483w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/wp_post-table-inside-phpMyAdmin-highlighting-a-post-ID-column.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1483px) 100vw, 1483px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\"><img decoding=\"async\" width=\"1660\" height=\"991\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/public\" alt=\"WordPress Theme Editor, highlighting the single.php file\" class=\"wp-image-57896\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=1660,fit=scale-down 1660w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-the-single.php-file.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1660px) 100vw, 1660px\" \/><\/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=\"\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\"><img decoding=\"async\" width=\"1659\" height=\"991\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/public\" alt=\"WordPress Theme Editor, highlighting code snippets.\" class=\"wp-image-57897\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=1659,fit=scale-down 1659w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/WordPress-Theme-Editor-highlighting-code-snippets.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1659px) 100vw, 1659px\" \/><\/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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\"><img decoding=\"async\" width=\"1024\" height=\"546\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/public\" alt=\"A website's post, highlighting a post ID.\" class=\"wp-image-57898\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/A-websites-post-highlighting-a-post-ID.png\/w=1536,fit=scale-down 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 specific posts, creating 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 solid 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 an ID. It functions as an identifier for each piece [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/wordpress-post-id\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":258,"featured_media":71566,"comment_status":"closed","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":[22643,22637],"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\/tutorials\/wp-json\/wp\/v2\/posts\/16808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/258"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=16808"}],"version-history":[{"count":26,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/16808\/revisions"}],"predecessor-version":[{"id":128897,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/16808\/revisions\/128897"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media\/71566"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=16808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=16808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=16808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}