How to add bubble count in WordPress wp_nav_menu menu?

For flexibility, you could assign the CSS bubblecount class to the corresponding menu item: and then target it with: if( in_array( ‘bubblecount’, (array) $item->classes ) ) $output .= ‘<span class=”unread”>’.my_function_here().'</span>’; in your code snippet above.

Adding a Nav menu to post admin

To see how such a list can be created look at the code in wp-admin/includes/nav-menu.php. Unfortunately, it is hard coded there, so you have to re-create the code. First, let’s create two menus: We can get these menus in PHP with wp_get_nav_menus() (a wrapper for get_terms()): $menus = wp_get_nav_menus(); print ‘<pre>’ . htmlspecialchars( print_r( $menus, … Read more

different Menu position showing same menu

I can see a syntax error: replace ‘theme-location’ by ‘theme_location’. Always think about underscores in WordPress variables/functions names 😉 wp_nav_menu() : https://codex.wordpress.org/Function_Reference/wp_nav_menu

Manipulating menu HTML

Use a custom walker. Extend the functions start_lvl() and end_lvl(): class WPSE39005_Div_Walker extends Walker_Nav_Menu { /** * @see Walker::start_lvl() * * @param string $output Passed by reference. Used to append additional content. * @return void */ public function start_lvl( &$output, $depth ) { $output .= ‘<div><ul class=”sub-menu”>’; } /** * @see Walker::end_lvl() * * @param … Read more

Add items to a menu dynamically

You could achieve this with a custom walker function, on your menu. a very simple example: class Walker_WPA82563_Submenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) { if( ‘Boats’ == $item->title ){ $output .= ‘<ul><li>Dynamic Subnav</li></ul>’; } $output .= “</li>\n”; } } Then where you call the nav menu, create an instance of your custom … Read more

Menu with Automatic Pages Included from Custom Post Type

This is accomplished by _wp_auto_add_pages_to_menu() (in \wp-includes\nav-menu.php) function that is hooked to transition_post_status hook. Unfortunately it is hardcoded for page post type and is not easy to extend. On other hand since it works through generic hook it isn’t hard (relatively, menus internal code is pain) to engineer analogue for custom post type.

Get menu links only

Use a custom walker: class WPSE_33175_Simple_Walker extends Walker { public function walk( $elements, $max_depth ) { $list = array (); foreach ( $elements as $item ) $list[] = “<a href=”https://wordpress.stackexchange.com/questions/33175/$item->url”>$item->title</a>”; return join( “\n”, $list ); } } … and then call wp_nav_menu() like this: wp_nav_menu( array ( ‘theme_location’ => ‘your_registered_theme_location’, ‘walker’ => new WPSE_33175_Simple_Walker, ‘items_wrap’ … Read more

Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out

It seems that the OP have managed to solve his/her problem by doing this, which can be found at Different menus for logged-in users. if ( is_user_logged_in() ) { wp_nav_menu( array( ‘theme_location’ => ‘logged-in-menu’ ) ); } else { wp_nav_menu( array( ‘theme_location’ => ‘logged-out-menu’ ) ); } The more shorter way to achieve that is … Read more

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