Create a menu item with a blank title

It took me forever to find a solution to this. I thought I would release my code here for anyone that needs an answer to this question. I had to use two functions in order to solve the problem. The first function replaces the blank label with   to prevent the deletion of the menu … Read more

Automatic Table of contents with categories and posts

Here is a plugin that does the same. function get_posts_per_taxterm($taxonomy, $term_id ){ $posts = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘field’ => ‘term_id’, ‘terms’ => $term_id, ‘include_children’ => false ) ) ) ); // `first_post_id` is a global variable which … Read more

WordPress Accessible Keyboard Menus

With that structure, try this: (note this makes assumptions about your base styles) // your working styles, trimmed down #menu-main-navigation li > ul.sub-menu { display: none; } #menu-main-navigation li:hover > ul.sub-menu { display: block; } // focus is on the link, not the li! #menu-main-navigation li a:focus + ul.sub-menu { display: block; }

Getting parent object_id of child menu items in WordPress menu

I made 2 mistakes in my comment. try rather this code function data_attribs_menu( $atts, $item, $args ) { // check if ACF exists if( class_exists(‘acf’) ) { $page_section = get_field( ‘page_section’, $item->object_id ); if( $args->theme_location == ‘header-menu’ ) { if( $item->menu_item_parent == 0 ) { $atts[‘data-color’] = $page_section; } else { $parentItem = get_post($item->menu_item_parent); $parent_page_section … Read more

Output existing wp_nav_menu with a custom walker

By default wp_nav_menu() outputs the navigation markup. If you want to store it or want to concatenate it with other string then you’d have to set the echo parameter to false (by default it’s true). $output .= ‘<ul class=”sub-menu”> ‘ . wp_nav_menu( array( ‘theme_location’ => ‘col_1’, ‘menu_id’ => ‘col_1’, ‘menu_class’ => ‘col_1’, ‘container’ => ”, … Read more