Check if current post belong to list of custom post types


<?php
    $args=array(
      'public'   => true,
      '_builtin' => false
    );
    $post_types=get_post_types($args,'name');
   
    foreach ($post_types as $post_type ) {
           
            //get_post_type() returns the post type of the current page.
           
            if ( $post_type->rewrite[slug] == get_post_type() )  {
                // Do Something (propabaly add a 'current' class)
            }
    }
?>

Latest Comments

Leave a Reply

comment on this article