Skip to content

Instantly share code, notes, and snippets.

@mihail-petrov
Forked from chriscoyier/gist:972314
Last active December 17, 2015 21:59
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 mihail-petrov/5678919 to your computer and use it in GitHub Desktop.
Save mihail-petrov/5678919 to your computer and use it in GitHub Desktop.
<?php
// returns boolean
function is_custom_post_type( $type = '' ) {
// access to currently queried post
global $post;
// get the current post type
$post_type = get_post_type( $post );
// all post types that aren't custom
$types = array("post", "page", "revision", "attachment");
// check if current post type is custom
if ( $type == '' && in_array($type, $types)) {
return true;
// if parameter passed, compare against that
} else if ( $type == $post_type ) {
return true;
} else {
return false;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment