How To Check If a Post is a Custom Post Type

WordPress has plenty of conditional tags that can be used to know what page or post are we in.

The simplest way to check if we are in a custom post type is to use is_singular():

if( ! is_singular( array('page', 'attachment', 'post') ) ){
    // echo 'Imma custom post type!';


If you look at WordPress hierarchy you’ll notice that the attachment, custom post, blog post, and page are all under the singular page parent. What the code above does is to check if the current page is NOT one of the core posts (page,attachment, or post).