WordPress assigns an ID to each post and page. You may need this number when configuring a plugin, referring to content in code or investigating a problem.
Find the ID in the editor
- In WordPress, open Posts or Pages.
- Click Edit for the required item.
- Check the editor URL for post=123, where 123 is the item’s ID.
Both posts and pages normally use the post parameter in this URL. You can also hover over an item’s Edit link to see the address without opening it.
Look it up in the database
If needed, use phpMyAdmin to browse the WordPress posts table. The prefix may differ from wp_. Find the item’s ID, checking its title and post_type because this table also contains attachments, revisions and other content types.
This is a lookup only; do not edit or delete database rows to obtain an ID.
Use the ID in a template
Developers can use WordPress’s existing function inside the Loop:
$post_id = get_the_ID();It returns the current item’s ID. Do not add an incomplete function declaration to functions.php; code outside the Loop needs an explicitly identified post or the appropriate queried-object function.