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
- How to get Author ID outside the loop
- How can I create a “Read More” link using the_excerpt() on a static front page?
- get all posts ID from a category
- What is an alternative to get_page_by_title()?
- Filter front page posts by category
- Get page id by title?
- How to add the category ID to admin page
- How to get page’s ID if I know the title only?
- Unable to load static front page on home url
- How to set a custom post type post as static front page?
- Custom background for the index page only?
- Creating a Front-end based User Search
- home.php or frontpage (via settings) for theme?
- How to display blog posts on a dedicated page?
- front end publishing not working on front-end page
- Get comment content by comment ID
- Get author ID with attachment ID
- WP Multisite Static Frontpage
- URL scheme to retrieve tag archive by ID
- Passing the page ID to a login php script
- Performing a POST action on homepage goes to posts page
- Loop on front-page.php
- Disable front-page.php template
- How to set up a single portfolio page as home page?
- How to view WordPress’ default category IDs?
- Shortcode for a link and thumbnail
- Arrange posts by date in front page
- Changed site URL and now my Front Page doesn’t display correctly
- Can’t see widget areas in my customizer
- How to Display a Plugin function (content) on frontpage using index.php
- How to add ID attribute to each submenu?
- Is it possible to change post id for an already added menu item in WordPress?
- Why wordpress kicks me back to the dashboard of xampp? [closed]
- Search results posts_orderby and ID
- Include sticky posts on the static page front page
- Retrieve post ID from “querying” URL
- How to I know the class or ID of my theme?
- Reusing content from front page on sub page
- how would i change post->ID to work correctly when querying pages?
- is_home and is_frontpage always true
- Front page is being directed to an unknown site
- get term id from term name
- upload image only
- What code controls the animation for the front-page header in TwentySeventeen
- Static page for desktop or mobile
- Showing “best posts” in front page
- php return username of currently viewed author profile
- Show posts on front page only
- Confused by the behaviour of “front page” / “home” templates
- How do post IDs work in WordPress?
- How to remove/replace current page template?
- How to get custom image field of specific post id
- static front page ONLY for certain themes?
- Display posts from an array of ID’s
- is_front_page use in sidebar.php
- “Home” Page now only displaying the single latest post
- Why is my insert row only inserting the final row from the loop into the database rather than just inserting one
- Custom Post Type with Sequence ID
- How to block specific user id in custom login form?
- Get current user id in function php
- Reuse old post ID for new post after deleting post
- get_current_user_id() always return 0 in if else statement
- Homepage rewrite rule
- Make pagination work as a carousel (custom query)
- Get attachment URL from attachment Link in WordPress
- How to detect if some page template has been selected
- How can i take all ids from untrash_post action?
- Store All Post Categories In Array
- Page WYSWIG only allowing slides
- I can’t enqueue Suggest.js in frontend – not added
- Categories with post from child categories on front page
- New WP_Query not isolating custom post types on front-page template
- Loop doesn’t display posts. It displays a link to the home page instead
- Font Page overrides rewrites
- Changing starting number of User ID
- Display selected parts from selected pages on the frontpage?
- unused post IDs
- Query specific posts from parent by slug rather ID
- WordPress loop: Display if posts exist
- No posts on front page
- Front page welcome message area
- What is $post->ID
- CPT posts in drop downed in meta box on page doesn’t return post ID
- Show custom category archive as front page and remove taxonomy slug from urls
- How to get post ID after removing that post?