Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'theme_mod_nav_menu_locations', function ( $menu ) {
- if ( is_category() || is_singular( 'post' ) ) {
- if ( is_category() ) {
- $category = [get_queried_object()];
- } else {
- $category = get_the_category();
- }
- $data = [];
- $cats = [0,0,0,0];//list of category id to change
- jnews_recursive_category(get_categories([
- 'include' => $cats,
- ]), $data);
- if ( array_intersect( $category, $data ) ) {
- $menu = is_array( $menu ) ? $menu : array();
- $menu['navigation'] = 0;//the menu id you wish to assign to the category.
- }
- }
- return $menu;
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement