WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
@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

share|improve this answer

You must retrieve the page via the function get_page.

Look for the post_status field in the returned object!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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