Is it possible to add a filter for the output of nav-menu items in admin?

These fields are created in Walker_Nav_Menu_Edit::start_el(). To change or to remove them, create a custom walker (example for another walker) that extends Walker_Nav_Menu_Edit and uses other or less fields. Then filter wp_edit_nav_menu_walker and return the class name of your walker. Pseudo-code: class Walker_Nav_Menu_Edit_Simple extends Walker_Nav_Menu_Edit { public function start_el( &$output, $item, $depth = 0, $args … Read more

Custom nav walker with different output depending on depth

Sounds like you want to check the $depth variable. A depth of 0 is a top level item, a depth of 1 is a child of a top level item, etc. So in keeping with your current code, you could factor out that logic this way: $format=”%1$s<a%2$s><div>%3$s%4$s%5$s</div></a>%6$s”; if( $depth > 0 ) $format=”%1$s<a%2$s><div class=”flintstone-nav”>%3$s%4$s%5$s</div></a>%6$s”; $item_output … Read more

Hide Admin menus per role in WordPress

you can do this, it hides the menu (thats all , they can still go to the menu url if they know it), based on capability. You can easily change it to role or even username. I think user role is “user_role” and for username it is “user_login”. The example below uses “user_level” of 10 … Read more

Dynamically add sub-categories to any category in the menu

you can add them with the filter wp_get_nav_menu_items add_filter(“wp_get_nav_menu_items”, function ($items, $menu, $args) { // don’t add child categories in administration of menus if (is_admin()) { return $items; } foreach ($items as $index => $i) { if (“category” !== $i->object) { continue; } $term_children = get_term_children($i->object_id, “category”); // add child categories foreach ($term_children as $index2 … Read more

How to activate “Description” metabox for menu item programmatically?

Remove the description from the user meta value managenav-menuscolumnshidden: add_filter( ‘manage_nav-menus_columns’, ‘enable_nav_menu_description_by_default’ ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = ‘managenav-menuscolumnshidden’; $hidden = get_user_option( $desc_key ); $user_id = wp_get_current_user()->ID; if ( ! $hidden ) { update_user_option( $user_id, $desc_key, array ( 0 => ‘link-target’, 1 => ‘css-classes’, 2 => ‘xfn’ ) ); } elseif ( FALSE … Read more

Adding a class (arrows) to main menu links that have children?

There are two ways of doing this: Javascript. You could use JQuery to select the <li> that have <ul> children of class ‘sub-menu’, inserting content, or appending a CSS class which you then style. For example: $(‘.sub-menu’).parent().addClass(‘myclass’) PHP, a new walker function. Copy the code from wp-includes/nav-menu-template.php (until approx line 109) into your themes functions.php … Read more

How to Use the Function is_user_logged_in To Display Different Menus?

i just did this for a site i am working on. first i registered 2 menus in functions.php: add_action(‘init’,’kia_menus’); function kia_menus(){ register_nav_menus( array(‘primary-menu’ => __( ‘Primary Menu for Logged In Users’, ‘kia_theme’ ), ‘primary-loggedout’ => __( ‘Primary Menu for Logged Out Visitors’, ‘kia_theme’) )); } and then where i want the 1 menu to appear … Read more

How to implement separate sub-menus?

I can somehow understand what you are asking for but I think you should make this more clear. You already posted an example, but I think the main problem is: You connect some type of data to each other which is not known to wordpress. So as long as you don’t provide some hint how … Read more

Not able to get current menu ID

As far as I’ve seen a menu object does not have the ‘current’ property, does it? Not that I ever seen it, at least. So you can get close to what you’re asking by comparing the current post/page ID (get_the_ID()) with the items’ object_id property, when they match – boom! you got your currently selected … Read more

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