Skip to content

Instantly share code, notes, and snippets.

@onishiweb
Created February 22, 2014 10:57
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 onishiweb/9152009 to your computer and use it in GitHub Desktop.
Save onishiweb/9152009 to your computer and use it in GitHub Desktop.
/**
* Work out the current post type
* - based on WP function or current taxonomy
* @author Adam Onishi (aonishi@wearearchitect.com)
*/
function dig_current_post_type() {
global $post;
if( ! is_tag() ) {
$type_name = get_post_type();
if( ! $type_name ) {
$taxonomy = get_query_var( 'taxonomy' );
$type_name = substr_replace($taxonomy, '', -9);
}
return $type_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment