How to check if page id(SomeID) is actually published?


You can use 'publish' === get_post_status( $id ), where $id could be the current page ID retrieved via get_the_ID() or any other.

  • @kaiser It's not really explicit that it's the current page he wants to check. At least that's not how I interpreted the question. – hampusn Sep 19 '12 at 17:03
  • You're right. I'll fix it. Just wanted to get it out of the review row - too short answers are flagged by the community user. – kaiser Sep 19 '12 at 17:03
  • Yeah I've noticed that several times. It's annoying when people forget to add back-ticks around php tags. Cheers :) – hampusn Sep 19 '12 at 17:05

You can try this:

  $page_id = 20; // example id of your page 
  $page = get_page( $page_id );
  if ($page->post_status == 'publish') {
    // page is published


You must retrieve the page via the function get_page.

Look for the post_status field in the returned object!

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.