Leverage the current_page_item class when listing custom post type pages with wp_list_pages in WordPress

Strangely, the current_menu_item class is not added when listing custom post type pages. Here's a small snippet to that.

Just change the nameOfYourCPT to your post type name.

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


And then when you list your custom pages:

$args = array(
    'post_type'   => 'work',
    'sort_column' => 'menu_order',
    'title_li'    => ''
wp_list_pages( $args );

You’ll get the nice current_page_item class added to the li:

<li class="page_item page-item-85 current_page_item">
    <a href="http://example.com/example-work/">
        Example work project

Club-Mate, the beverage → club-mate.fi