Doesn’t WordPress already at the class current_page_parent
, current_page_ancestor
and current_page_item
(see source). The filter you are using is called on 1046.
As for your question, you create the array $content_type
and then attempt to make a string out of $the_content_type
.
Try:
function wpse56088_page_css_class( $css_class, $page, $depth, $args, $current_page ){
$terms = get_the_terms( $page->ID, 'content-type' );
if ( $terms && ! is_wp_error( $terms ) ){
$term_names = wp_list_pluck($terms,'name');
//Add term names to array of classes
$css_class = array_merge($css_class, $term_names);
}
return $css_class;
}
add_filter( 'page_css_class', 'wpse56088_page_css_class', 10, 5 );
Note $css_class
is suppose to be an array of class names.