I'd like to add a workaround that worked in my situation.
I had Custom Post Type with Custom Taxonomy and wanted to list these posts as long as they were in a particular Custom Category - with current page class on the li
.
The code above*
produced a list of all posts, but didn't filter categories.
*
[editor note] Answers may vary its order, not sure what code is being referred.
My solution comes from that code, not sure if it's best practice, but it works..
<?php
// get current page/post ID
$pageID = get_the_ID();
query_posts( array( 'post_type' => 'developments', 'custom_cat' => 'current' ) );
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
// test if current page/post ID matches
if ( $post->ID == $pageID ) {
$class = 'current_page_item';
} else {
$class = '';
}
?>
<li <?php if ($class != '') echo 'class="'.$class.'"'; ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php
endwhile;
endif;
wp_reset_query();
?>