How to check if page has status published

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

Related posts

Leave a Reply

3 comments

  1. You can try this:

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