Determine if a navigation item has children

You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more

Using Different nav_menu_css_class for different nav_walkers

The third parameter passed into nav_menu_css_classes should give you the information you need to sort out the different menus. Try: function onpage_nav_menu_css_class($classes, $item, $args) { var_dump($args); return $classes; } add_filter(‘nav_menu_css_class’, ‘onpage_nav_menu_css_class’, 1, 3); Note: That will make a mess of your page. It is debugging/development only code. I think that the theme_location should be sufficient … Read more

Customize Walker_nav_menu to show posts if item is category

You could either extend the Walker_Nav_Menu walker class (i.e., the start_el function is sufficient, as already mentioned). Or you could hook in when the original output (i.e., the category) has been created. That would be the walker_nav_menu_start_el hook. For instance like so: function wpdev_139801_start_el( $item_output, $item ) { if ( isset( $item->object ) && $item->object … Read more

Help with output of post classes using apply_filters

Solved it with generous help using join()… function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0) { if ( $depth ) $indent = str_repeat(“\t”, $depth); else $indent=””; extract($args, EXTR_SKIP); $output .= $indent . ‘<li id=”item_’.$page->ID.'” class=”‘.join( ” “, get_post_class( “”, $page->ID )).'”><span>’.apply_filters( ‘the_title’, $page->post_title, $page->ID ).'</span>’; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)