Adding class “current_page_item” for custom post type menu

I am using the following to help display a list of posts created in a custom post type.

$args = array(
  'post_type'=>'portfolio',
  'title_li'=> __('Portfolio')
);
wp_list_pages( $args ); 

However a class is not being added to the list item of the current page (current_page_item). Any ideas of how I could make this happen?

6 Answers
6

Check this ticket: http://core.trac.wordpress.org/ticket/17590

Quickfix by husobj:

function my_page_css_class( $css_class, $page ) {
    global $post;
    if ( $post->ID == $page->ID ) {
        $css_class[] = 'current_page_item';
    }
    return $css_class;
}
add_filter( 'page_css_class', 'my_page_css_class', 10, 2 );

The quickfix might be an easier alternative?
Cheers

Leave a Comment