I'm building a Wordpress plugin in which I need to get the HOME page ID value.

Do you know how can I get it?

I know that we can get the current ID with the_ID() or get_the_ID() function, but I need specificly the HOME page ID value.

My plugin is located at the following directory path:

  • Are you using front-page.php or you created a specific page just to be the home page of your website? If you used front-page.php (or index.php), then you don't have any ID associated with it. – Bruno Monteiro Sep 18 '15 at 18:37
  • The homepage do not have an ID – Pieter Goosen Sep 18 '15 at 18:41
  • Can you elaborate on your roadblock requiring the homepage ID? I can't seem to imagine a scenario where using is_front_page() and writing a slightly longer function wouldn't solve every problem. – deflime Sep 18 '15 at 19:07

$pageID = get_option('page_on_front'); should get you the Page ID of the page set at 'Front Page' in WordPress options.

  • Home page is the posts page - this is the option for the Front page, which might colloquially be known as the home page, but in WordPress means something different. – SinisterBeard Jun 20 '17 at 9:05

If by Home Page you mean the page designated as the Posts page, the ID is stored in the option page_for_posts. If the value is 0, there is no designated home page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.