Simple Function to check for post type
Here is a simple usful function i use to check for a specific post type:
function is_post_type($type='post') {
global $post_type,$typenow;
if (isset( $_GET['post_type'] )&& $_GET['post_type'] == $type
|| isset( $post_type ) && $post_type == $type)
|| isset( $typenow ) && $typenow == $type)
return true; // return true if on a page of type $type
return false;
}
usage:
if (is_post_type('slider')){
// the post type is slider :)
}
Written by raz ohad
Related protips
1 Response
WordPress provides the is_singular() function for checking the current post type(s):
http://codex.wordpress.org/Function_Reference/is_singular
Hope it's useful :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#