Get menu object from theme_location

This method looks like what you’re looking for, using get_nav_menu_locations() and get_term(): $theme_locations = get_nav_menu_locations(); $menu_obj = get_term( $theme_locations[$theme_location], ‘nav_menu’ ); $menu_name = $menu_obj->name; (See the link for the whole thing wrapped up in a custom function; the above code just highlights the relevant WP functions for getting what you’re after.)

How do I get the name of a menu in WordPress?

You can access the menu metadata using the wp_get_nav_menu_object function BY NAME: $menu = wp_get_nav_menu_object(“my mainmenu” ); BY SLUG: $menu = wp_get_nav_menu_object(“my-mainmenu” ); The return object as follows: Object ( term_id => 4 name => My Menu Name slug => my-menu-name term_group => 0 term_taxonomy_id => 4 taxonomy => nav_menu description => parent => 0 … Read more

Change the_title() of a page dynamically

I would use the is_page_template() conditional: if ( is_page_template( ‘page-courses.php’ ) ) { // The current page uses your // custom page template; // do something } Edit You would use this conditional inside your filter callback: function wpse83525_filter_the_title( $title ) { if ( is_page_template( ‘page-courses.php’ ) ) { return ‘Custom Title’; } return $title; … Read more

Mega Menu Walker

If I understand the problem setup correctly, you could try to do the break and widget class counting within the wp_nav_menu_objects filter. Here’s an updated example, it’s rather expanded because of the extra debug part: add_filter( ‘wp_nav_menu_objects’, function( $items, $args ) { // Only apply this for the ‘primary’ menu: if( ‘primary’ !== $args->theme_location ) … Read more

Remove a menu item in menu

I think the best way to remove a menu item from a menu is by hooking to wp_nav_menu_objects filter (@Otto answer from the thread you mentioned). And the way you use is first check for the correct menu to filter, and then search for the menu item and remove it by unsetting it from the … Read more

Add Class to Specific Link in Custom Menu

you can use nav_menu_css_class filter add_filter(‘nav_menu_css_class’ , ‘my_nav_special_class’ , 10 , 2); function my_nav_special_class($classes, $item){ if(your condition){ //example: you can check value of $item to decide something… $classes[] = ‘my_class’; } return $classes; } Using this $item you can any condition you want. and this will add the class to the specific li and you … Read more

Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu

I get this error when there are no menus defined or no menus set for the location at Appearance->Menus. When that occurs wp_nav_menu uses a page walker fallback. The fallback (default) for wp_nav_menu is wp_walker_page which uses wp_page_menu which uses wp_list_pages which uses walk_page_tree which uses Walker_Page not Walker_Nav_Menu. And apparently the two walkers are … Read more

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