wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Check for post type within loop using get_post_type

wordpress snippet

Adding this snippet within the loop of your wordpress theme will let you conditionally check for a specific post type. Just change the post type ‘products’ or ‘people’ to the post type you would like.

snippet :  PHPcopy
if ( 'products' == get_post_type() ){
           ... code to run if products post type...
}elseif ( 'people' == get_post_type()){
           ... code to run if people post type...
}else{
           ... code to run if neither of above post types...
}

Did you like this post? If so please share it with your friends. Thanks!