You are not providing the correct parameter to wp_get_nav_menu_object()
function. It needs the menu ID or menu slug but you are providing the menu theme location. Obviously, I can not tell you what is the ID or slug of your menu.
One way of getting the menu ID of the menu assigned to theme location is using get_nav_menu_locations()
:
$menu = wp_get_nav_menu_object( get_nav_menu_locations()['primary'] );
echo $menu->count;
Related Posts:
- Extend walker – navigation, adding data attribute to a tag
- Hide Login information in Account settings in Buddy Boss
- Add clickable arrows to parent menu items with children elements e.g. with
- How to wrap the list with custom class using wp_nav_menu?
- Help with walker for nav
- Sticky menu for WP custom menubars
- Insert menu with a custom walker into page / post body using shortcode?
- Implement a Walker with custom object rather than WordPress database object
- Position a hard-coded menu item
- How to request container_class from wp_nav_menu
- How to add active state to the navigation links?
- Customize Widget Navigation
- Custom menu not showing even though it shows as being registered?
- Current menu item highlights wrong
- remove or hide Link Relationship (XFN) form Menus tab
- Class .current-menu-item in custom menu Walker
- removing extra mobile menu from the header
- Custom Menu (only showing direct cildren) ACF not showing
- Remove wrapping div and ul from output of wp_nav_menu
- Custom Walker: how to get ID in function start_lvl
- Split up wp_nav_menu with custom walker
- Mega Menu Walker
- Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?
- Add custom html to last sub-menu item
- Call custom field into menu item
- add span class inside wp_nav_menu link anchor tag
- Determine if a navigation item has children
- wp_nav_menu() custom container and container_id
- Show a WP 3.0 Custom Menu in an HTML Select with Auto-Navigation?
- global menus made from master site’s custom menus wpmu network
- Add Page ID class to nav menu items
- Walker class: Problems with understanding how walk() method can be called without error
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- Adding Post Counts to Menu (Nav) Programmatically?
- wordpress custom walker for thumbnails with custom menu
- Bar separated navigation by extending Walker_Nav_Menu
- Bar separated navigation by extending Walker_Page
- Custom Nav Walker sub-menu HTML construct
- Change default status and replace the icon for an hamburger menu
- simple expandable vertical menu, java script problem
- wp_nav_menu custom walker – child items
- wp_nav_menu doesn’t generate parent/ancestor classes
- Create a Custom menu item fetched by Product Categories and Sub Categories
- Can this navigation be done easily in WordPress?
- how to change WordPress menu markup/classes
- wp_nav_menu google analytics event tracking
- Only append custom classes to nav menu items
- `start_el` depth argument in custom nav walker always evaluates to zero
- Benefits of using Nav Walker?
- Outputting Page Content in Two Places
- How to extend nav-menu-item-control data in Appearance > Customize?
- Use walker for specific menu, or avoid use of walker
- How to display dynamic content in start_lvl function
- Comments not nesed with custom template
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- Add custom text to menu
- How can I get the page url slug when ‘post_name’ returns an id?
- has_children in custom nav_walker
- Multiple menu items highlighted
- Adding post excerpt into navigation menu
- Use wp_nav_menu to display ALL pages
- Third level navigation class
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Nav Menu – Add class based on meta keys
- Adding all sub-pages to the menu manager
- add JS to multiple plugin admin pages
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- How do I create page navigation linking to each H2 within the page? [closed]
- Putting tag outside tag on generated Menu
- add span class and i tag inside wp_nav_menu link anchor tag
- Change an li class name in a wordpress custom menu walker
- How do I separate link levels in a custom menu walker?
- Add within the output of
- URLs and navigation in custom themes
- How to create left and right menu with logo center in a custom theme?
- How Do I Remove The Right Hand Block On The Main Header?
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Is this format possible with a custom Nav Walker class?
- Adding posts to custom menu [closed]
- walker – 0 level on submenu formatting
- Determine the last child of the parent menu WP Nav Walker
- Alphabetical Custom Menu
- Sub menu indicator that links to sub menu
- Create menu / submenu from category subcategory and posts
- Navigation doesn’t render when wp is hosted
- Navigation label for page in custom theme
- Custom Navigation build using wp_nav_menu and walker
- How do you add a around the second level of a Menu?
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Using my WordPress menu on another platform
- WPML Plugin Not displaying multilingual Menus
- Using _s theme, menu changes do not affect header menu
- how to display a specific wordpress menu?
- How to remove dropdown from wp_nav_menu
- How Do I Add Images To Main Navigation Menu
- Create a url structure for my blogs based on categories and sub-cats
- Looking replicate static HTML Menu into WordPress Dynamic Menu [closed]
- Walker menu not displaying at all
- Custom font size nav bar
- Add login hyperlink to secondary navigation menu