Guest User

is_post_type function

a guest
Sep 17th, 2010
201
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function is_post_type($post_type = '', $item = '') {
  2.     global $wp_query;
  3.     $type_obj = $wp_query->get_queried_object();
  4.     $post_type = (array) $post_type;
  5.  
  6.     if( in_array( $type_obj->post_type, $post_type ) && empty( $item ) )
  7.         return true;
  8.  
  9.     if( in_array( $type_obj->post_type, $post_type ) ) {
  10.         $item = (array) $item;
  11.    
  12.         if ( in_array( $type_obj->ID, $item ) )
  13.             return true;
  14.         if ( in_array( $type_obj->post_title, $item ) )
  15.             return true;
  16.         if ( in_array( $type_obj->post_name, $item ) )
  17.             return true;
  18.     }
  19.  
  20.     return false;
  21. }
RAW Paste Data