Created
November 5, 2019 14:08
-
-
Save wpbean/914546c9abf3fa03ce95ddf03a11e42d to your computer and use it in GitHub Desktop.
Add custom post type support for WPB accordion menu and category post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wpb_wmca_category_css_class', 'wpb_wmca_add_support_single_doc', 10, 4 ); | |
function wpb_wmca_add_support_single_doc($css_classes, $category, $depth, $args){ | |
if( is_singular( 'docs' ) ){ | |
if ( ! empty( $args['current_category'] ) ) { | |
if ( $args['current_category'] === $category->term_id ) { | |
$css_classes[] = 'current-cat'; | |
} | |
} | |
if ( $args['has_children'] && $args['hierarchical'] && ( empty( $args['max_depth'] ) || $args['max_depth'] > $depth + 1 ) ) { | |
//$css_classes[] = 'current-cat'; | |
} | |
if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $category->term_id, $args['current_category_ancestors'], true ) ) { | |
$css_classes[] = 'wpb-wmca-current-cat-parent'; | |
} | |
} | |
return $css_classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment