Add class to all list items of wp_nav_menu

There is a nav_menu_css_class filter. It is trivial to add classes. function add_classes_wpse_130358($classes, $item, $args) { $classes[] = ‘new-class’; return $classes; } add_filter(‘nav_menu_css_class’,’add_classes_wpse_130358′,1,3); But you will probably need to extend Walker_Nav_Menu or use the walker_nav_menu_start_el filter instead, since the nav_menu_css_class filter mysteriously does not have access to the depth variable. But walker_nav_menu_start_el doesn’t let you … Read more

Override custom menu widget

Ok, here we go. I extended the default Navigation widget for you. Add this to your themes functions file. After you have done this, go to widgets in your dashboard and you will see a widget called ‘Matt Royal Custom Menu’ now. Use this one. In the below code, the div class has been added … Read more

Custom Menus Description Stripping HTML Tags

(Untested). But if you want to use HTML in the description, then you shouldn’t use: `esc_html( $item->description )` Try removing the esc_html as this escapes the HTML. (Or better still use wp_kses instead to only allow certain tags.). So you want $description = ( ! empty ( $item->post_content ) and 1 == $depth ) ? … Read more

Generate a Menu that displays all child pages of top level parent

Here is a function that will output the top level parent along with all of the children of the current page. Helpful menu classes are added to the output. E.g. page_item_has_children, current_page_item, current_page_ancestor, etc. This solution is based on one of the examples in the documentation for wp_list_pages() and this answer here on WPSE, which … Read more

Organizing by super-categories (or nested categories)?

Hi @NealWalters: This is obviously more of an opinion question rather than a technical one but here’s my opinion. My advice: use no more than 10 categories. Those <=10 categories when viewed together should define the essence of your blog. Don’t use subcategories. Then use lots of tags to define the topics you are talking … Read more

WordPress wp_nav_menu within iFrame

To get a working nav menu WordPress needs to be set up complete. My suggestion is to use add_feed(). Ignore the name, you get text/html as output. Let’s start with code <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Iframe Nav Menu Description: Display a nav menu in an iframe. Version: 2012.05.18 Refresh … Read more

List parent item with all child item on child pages

function wpb_list_child_pages() { global $post; $parent = “”; if ( is_page() && $post->post_parent ) { $parent = wp_list_pages( ‘title_li=&include=” . $post->post_parent . “&echo=0’ ); $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=” . $post->post_parent . “&echo=0’ ); } else { $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=” . $post->ID . “&echo=0’ ); //$parent = $post->post_title; } if ( $childpages ) { $string … Read more

Adding Additional Menus In Genesis Child Themes

Here’s 2 options: First: The code goes in your child themes functions file and creates one extra menu which displays in the genesis_after_header position. There are 2 steps needed to add new nav menus. One. Register the menu(s) using the init action hook NOT after_theme_setup Two. Hook the menu into a theme hook location ( … Read more

Add class to active top level (grandparent) menu item

Styling the top-level item if it’s active or a child is active is possible with pure CSS. Use the child selector, >, from the top: .sidebar-navigation > ul > .current-menu-item, .sidebar-navigation > ul > .current-menu-ancestor {} If you want to add a new class, you can use the nav_menu_css_class filter. One of its parameters is … Read more