How to hide Newsletter plugin submenus from the Dashboard?

Use the action admin_menu as opposed to admin_init. You also need to adjust your use of remove_submenu_page to match the way Newsletter adds menu items: remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_index’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_main’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_main_diagnostic’ ); remove_submenu_page( ‘newsletter_main_index’, ‘newsletter_subscription_profile’ );

Add menu headings to WordPress sub menus

I ended up removing that code from my functions.php file and used jQuery instead. Here’s how I took care of it, if anyone wants to know: $(‘.menu-item-has-children > a’).each(function(){ var submenuHeading = $(this).text(); $(‘.sub-menu’, ($(this).parent(‘.menu-item-has-children’))).prepend(‘<h3>’ + submenuHeading + ‘</h3>’); });

If current menu item is child or parent with child?

I agree with ialocin, if you can use the built-in nav menu css classes you should but if those aren’t enough there’s a nice little filter which can help with css classes. If you need something other than CSS classes you can use a Custom Walker ( as ialocin suggested ) and use the same … Read more

How to hightlight all ancestor menu items of a child page NOT displayed in menu

You are checking against just one parent item. Instead, you might check against all of the parents <?php //in functions.php add_filter(‘nav_menu_css_class’, ‘highlight_portfolio’, 12, 2); function highlight_portfolio($classes, $item) { $parents = get_post_ancestors(); if ( 0 < count($parents) ) { if ( in_array( $item->object_id, $parents ) { array_push( $classes, ‘current-menu-ancestor’ ); } } return $classes; } Notice … Read more

WordPress Custom Menu Admin helper plugin

Add this to functions.php, or put the CSS into a css file which is loaded in the admin screen. This will let the box become resizable, so you can make it taller and see more pages/checkboxes at once. function wp191833_resize_menu_list() { ?> <style type=”text/css”> #wpwrap .categorydiv div.tabs-panel, #wpwrap .customlinkdiv div.tabs-panel, #wpwrap .posttypediv div.tabs-panel, #wpwrap .taxonomydiv … Read more

Replace anchor tag with span tag

The following code added to your themes functions.php will do what you want. add_filter( ‘walker_nav_menu_start_el’, ‘my_walker_nav_menu_start_el’, 10, 4 ); function my_walker_nav_menu_start_el( $item_output, $item, $depth, $args ) { if ( empty( $item->url ) || ‘#’ === $item->url ) { $item_output = $args->before; $item_output .= ‘<span class=”my-class”>’; $item_output .= $args->link_before . apply_filters( ‘the_title’, $item->title, $item->ID ) . … Read more