$request['post_type']
should contain the requested post type for any custom type. The default post
type will have a name
, but no post_type
. Pages will have pagename
and no post_type
.
EDIT- determining custom post type based on taxonomy set in request:
function cpt_request_filters( $request ){
if( ! is_admin() ){
global $wp_taxonomies;
foreach( $request as $tax_key => $value ){
if( array_key_exists( $tax_key, $wp_taxonomies ) ){
return cpt_parse_taxonomy_string( $request, $wp_taxonomies[$tax_key]->object_type[0], $tax_key );
}
}
}
return $request;
}
add_filter( 'request', 'cpt_request_filters' );