This should do the trick.
global $wp_query;
$post = $wp_query->get_queried_object();
$post->ID;
This’ll give you the ID for each page you’re on.
get_option( 'page_on_front' )
should’ve worked though.
Related Posts:
- Get previously visited page ID
- ID for posts/blogs page
- Get ID of “root-page”
- Get the correct post id for all post and page in header.php
- Get users between user ids
- Always Encounter Using ID in WordPress as a Final Solution [closed]
- Why does the page/post ID keep growing when i refresh the post-new.php file?
- How can I exclude a specific ID from this line of code?
- get page id’s – not get pages?
- get post by nav id
- Ad units Div-ids frequently changing
- Consequence of the post auto incrementer off?
- Subcategory IDs in relation to parent category ID switch case
- add anchor tags rel to thumbnails id
- get_pages gives wrong ID for blogpage
- When to use is_home() vs is_front_page()?
- Get page ID of page that is set as the posts page
- How to get current page ID outside the loop?
- how to get page id of a page using page slug
- get post author id outside loop
- Using pre_get_posts on true pages and static front pages
- How to get Author ID outside the loop
- Custom Walker: how to get ID in function start_lvl
- How to get page title with the page ID?
- How to get permalink and title from post ID?
- How do I get the current edit page ID in the admin?
- Programmatically set page_on_front
- Echo author ID in author.php
- Get page IDs from nav items
- How to get home page ID?
- How can I create a “Read More” link using the_excerpt() on a static front page?
- is_front_page() malfunction?
- Are post ID’s reliable?
- Get current post id in functions.php
- get all posts ID from a category
- How to add “Stick this post to the front page” to front end?
- How do I fetch the static front page using the REST API?
- How to obtain the user ID of the current profile being edited in WP-Admin?
- Ways to have multiple front-page.php templates that can be swapped out?
- is_front_page only works in theme file, and does not work in functions.php
- Creating a WordPress admin page without a menu for a plugin
- What is an alternative to get_page_by_title()?
- What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?
- Settings API – creating reusable form elements?
- Category page doesn’t use category.php, instead it redirects to homepage
- Get the current post ID as a variable in Javascript
- How to put custom post types on front page
- Is post ID number always incremental n+
- Can’t get post ID in functions.php?
- How to prevent the default home rewrite to a static page
- Facebook comments box on front page
- Filter front page posts by category
- Get page id by title?
- How to add the category ID to admin page
- How to make my front page display only the most recent sticky post, plus usual widgets?
- How does WordPress decide what template to use as frontpage
- Post ID At The End Of Permalink URL Effects Performance (Positively)?
- Custom query_var causes displaying posts archive on front page
- Importing posts from old website to new conflicting post ID’s?
- How do I show sticky posts on a static front page that also contains content?
- Static page homepage not showing the_content
- Get All IDs Of A Post Type Using WP_Query
- Get user id from email?
- How to change WordPress user ID?
- How to get page’s ID if I know the title only?
- How do I set the front page programmatically?
- front-page.php stylesheet
- Unable to load static front page on home url
- Getting the ID of a meta box
- How to set a custom post type post as static front page?
- index.php not loading in main folder of wordpress
- Is there an equivalent of the PHP function sanitize_key in Gutenberg?
- Are all ID’s used unique?
- How to create custom home page via plugin?
- Add Adsense code in index.php
- get all page IDs from wp_list_pages
- Custom background for the index page only?
- $post->ID displays wrong ID
- wordpress Static Page pagination
- Pagination causes error 404 when used with front-page.php
- wp_title() empty on a static front page
- Add category to custom post type automatically, using category slug
- Paginated pages are showing correct content but pagination links are not
- Load front-page.php from subfolder
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- How to show taxonomy meta on frontpage?
- How to get any tag ID
- get_post_meta fields don’t show up on posts page
- Possible to create a new post and have the Title and Slug automatically use the post’s ID?
- How to check if current static page is frontpage from admin plugin
- Trying to exclude first 5 posts from the first page on the homepage
- Set front page as static page [closed]
- Using add_rewrite_rule() to redirect to Front Page
- Index showing source code
- Show ids of displayed media library items
- Add rewrite rule to call front-page.php?
- How do I display Youtube/Vimeo video ID on custom post type when user enters it in custom meta box?
- Showing random content / pictures from earlier posts in a sticky post?
- On Category page, How can I get the category ID?
- Get the post_id of a new post