Display only page specific sub menu items using Custom Walker

Here is a much simpler implementation: class UL_Submenu_Walker extends Walker_Nav_Menu { private $hidden = false; function start_lvl(&$output, $depth) { if($depth == 0) { $style = $this->hidden ? “” : “display:none;”; } $output .= “<ul class=\”submenu-“.$depth.”\” style=””.$style.””>”; } function start_el(&$output, $item, $depth, $args) { $class_names = $value=””; $classes = empty( $item->classes ) ? array() : (array) … Read more

Calling the Menu Title within wp_nav_menu array function

You can not get the menu title using wp_nav_menu(), you need to get the menu object as follow: //Change with the ID of your menu $menu_ID = 5; $nav_menu = wp_get_nav_menu_object( $menu_ID ); // then echo the name of the menu echo $nav_menu->name; With the above code, you can insert the menu name in wp_nav_menu() … Read more

register_nav_menus() won’t register menus

You don’t need to add any action to register your Nav Menu. Here are some quick steps for you to get your WordPress Nav Menu to work… Register Nav Menu if (function_exists(‘register_nav_menu’)) { register_nav_menu(‘header_menu’, ‘Header Menu’); } Define and Use Nav Menu in your Theme: Usually we place the Menu DIV code in header.php file; … Read more

WordPress Shortcode in Menu Item Title

First of all download ‘Shortcodes in Menus’ plugin and install/activate it. Then in theme’s function.php add following code. add_shortcode( ‘current-username’ , ‘ss_get_current_username’ ); function ss_get_current_username(){ $user = wp_get_current_user(); return $user->display_name; } Now, in menu’s navigation lable write [current-username] shortcode. Same thing you can do for displaying avatar. This way it will display logged in user … Read more

fall back for main menu?

The parameter fallback_cb will be used when the user has no menu assigned to your theme_location. It should be a function that returns a string, but you can use __return_false() to suppress any output: wp_nav_menu( array( ‘theme_location’ => ‘primary’, // No menu available: no output. ‘fallback_cb’ => ‘__return_false’ ) ); You should always declare the … Read more

How does a minimal menu walker look like?

You could create a very simple walker, like this one. To detect the current item, inspect $item->current. It is TRUE for the current item only. I wouldn’t add a class, but deactivate the useless link completely, because it doesn’t have to be clickable anyway. Example: class One_Line_Walker extends Walker { public function walk( $elements, $max_depth … Read more

Unregister Nav Menu from Child-Theme

The Starkers theme setup is hooked to after_setup_theme, at a priority of 10. So you basically have to wrap the unregister function inside another function (child themes functions.php file) and add it later than the parent themes setup function, so it gets first added by the parent and later on removed by the child. function … Read more

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