Skip to content

Instantly share code, notes, and snippets.

@cdevroe
Created January 6, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdevroe/a3c754e94d4e0b597105 to your computer and use it in GitHub Desktop.
Save cdevroe/a3c754e94d4e0b597105 to your computer and use it in GitHub Desktop.
WordPress is_published is_draft functions
<?php
/**
* Determine whether a post or page is published or not.
*
* @return bool
*/
function is_published(){
$post = get_post();
if ( $post->post_status == 'publish' ) return true;
return false;
}
/**
* Determine whether a post or page is published or not.
*
* @return bool
*/
function is_draft(){
$post = get_post();
if ($post->post_status == 'draft') return true;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment