[wp-testers] is_post_type not working correctly

Michael E. Hancock justmichaelh at gmail.com
Fri Jun 4 17:11:15 UTC 2010


From: <hedwig at senzafineonline.net>

>I tried with is_singular() but it didn't work.
>
> This is the code I used and worked before RC1 and RC2
>
> $movie_pages = query_posts(array(
> 'orderby' => 'title',
> 'posts_per_page' => -1,
> 'post_status' => 'publish',
> 'movie' => $movie_title
> ));
>
> if ( have_posts() ) : while ( have_posts() ) : the_post();
>
> if ( is_singular('video') )
> $videos .= '
> <li><a href="'. get_permalink() .'" title="'. get_the_title () .'">'. 
> remove_movie_title( get_the_title() ) .'</a></li>';
>
> if ( is_singular('gallery') )
> $gallery .= '
> <li><a href="'. get_permalink() .'" title="'. get_the_title () .'">'. 
> remove_movie_title( get_the_title() ) .'</a></li>';
>
> endwhile; endif;
>
> What the code did was query all the post related to the current film,  and 
> group them by post type to use in the sidebar menu. With the RC  versions 
> now it doesn't distinguish between post types and each  section show ALL 
> posts rather than just the matching post types (i.e.  video or gallery)
>
> Using is_singular() doesn't display anything at all.
>
> You can see my sidebar menu functionality here: http:// 
> moviefy.senzafineonline.net/movies/prince-of-persia-the-sands-of-time


Now I see what scribu wanted with is_post_of_type in 
https://core.trac.wordpress.org/ticket/12588 but I don't think that made it 
into core.

Try

 if ( 'video' == $post->post_type  )




Michael 



More information about the wp-testers mailing list