hi
my problem about template hook and detect post type
this code don't work!
add_filter('template', 'echo_post_type');
function echo_post_type($template){
if ( !is_admin() ) {
global $wp_query;
echo $wp_query->post->post_type;
//or
global $post;
echo $post->post_type;
exit();
}
}
why?
What are you trying to do? Display or act on the post_type outside of the admin page i.e. within a post or page?
As you probably know the is_admin() checks if you are on an admin page and not if you are an admin user.
You might have better luck with this instead (if you want to work with the post).
add_action( 'the_post' , 'echo_post_type' );
tnx, i need detect post type for change website theme
in page setting plugin, user can specific theme for post type (example: news).