buuut the problem is that the list of elements is outside the ul of
the menu in itself.
I think part of the problem might be that wp_list_categories()
is in echo-mode by default so $latestpost
is always empty.
Please try it with these parameters instead:
// Get the categories
$latestpost = wp_list_categories( array(
'orderby' => name,
'show_count' => 0,
'exclude' => 3,
'title_li' => "",
'echo' => 0,
) );
You can see the default arguments of wp_list_categories()
here in the Codex.
The problem with your code example is also that the output of wp_list_categories()
is an HTML string, not an array. So this part: $latestpost[0]->ID
has no meaning when $latestpost
is an (empty) string.
Related Posts:
- How do I get my wp_nav_menu single category page to highlight the parent?
- Highlight current category, when using get_categories
- Automatically adding categories and authors in custom menu?
- Give child-categories same class (the parent category-slug) as parent in menu list?
- Product categories are mixed when creating menu
- How to select single category in menu if post have two categories?
- How to make a drop down menu with categories
- Unregister Nav Menu from Child-Theme
- Deleted pages are NOT removed from custom menus?
- Keeping parent menu items active in child pages
- Reflect nested categories in appearance > menus
- Add Page ID class to nav menu items
- Way to bulk delete menu items in new 3.x Appearance > Menus system?
- Pass a parameter to a menu walker
- Menu is not visible in appearance
- WordPress nav_menu_link_attributes Not Working
- Customize the menu by adding items
- wp_nav_menu log in/out link?
- Accesibility problems with dropdown menus in twentyten theme or others
- Automatically add product_categories to nav_menu
- Add Product categories to WordPress menu without losing hierarchy
- Theme menu in Admin Panel
- How to target children of child pages
- How to insert custom code into wp_nav_menu structure?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- WordPress Admin Bar Covering & Overlapping Fixed Menu Header [closed]
- getting parent page id when using custom menu.
- Change name & menu_name for Profile in the default menu, w/o altering core files?
- wp-menu ‘automatically add custom taxonomy terms’ like it does for pages? [closed]
- SlickNav – Google Lighthouse Accessibility issue for collapsed menu button
- How I can overlap my menu in my header picture
- current-menu-item class in CSS
- Put class on instead li
- Tiles as a navigation
- How to make the Primary Menu stay the same in the PC and mobile versions of the Twenty Sixteen theme
- How to add notifcations to front-end menu for users when they recieved replies?
- Page content loading issue using Walker_Nav_Menu
- Custom Walker for wp_list_categories
- Links do not open from click, only in new tab [closed]
- Default menu editor with automatic page list
- Can I have custom post types in “Add menu items” on in the Admin > Appearance > Menu
- Add a custom class to nav li item
- Hooking to walker_nav_menu_start_el to insert list of subpages
- Adding anchors in WordPress Menus
- Adding a unique ID to each sub-menu
- How to add css to single navigation text? [closed]
- My navigation menu isn’t working. What happened? Please help!
- How to get a multidimensional array of my menu?
- How to get the name of the homepage’s menu?
- How to add search to menu?
- How to get submenu of admin menu?
- How to get category id’s which are added in main menu?
- wp_nav_menu without menu or theme_location specified
- What is the $menu parameter used of in wp_nav_menu()?
- Show wp_nav_menu() based on URL with no fallback
- Editing the nav menu?
- How to display conditional menus with Twenty-twenty two theme (and other new block themes)?
- Keep source page URL parameters on custom link menu item
- I’m trying to remove a duplicate menu, which only appears on the homepage?
- Embedding an external webpage within a page? Is it possible, is it a good idea?
- How to remove empty line space in navigation menu?
- Is it possible to get_the_post_thumbnail (Featured Image) inside a sprintf function?
- Display menu in category and sub category
- WP Menu editor is hiding options for menu items
- Show alternative menu based on page template AND post category
- Assign a different menu depending on custom taxonomy
- Appearance -> Menu editor completely unresponsive
- Custom menu is rendered in all menus
- javascript i wrote not working, can’t figure out why [closed]
- Making my main menu a hamburger menu on all platforms
- menu change after theme change
- how to create pages and link them to a menu
- menu mobile show up even i in desktop mode in Newspaper Theme
- WordPress fountainpress header is covering top bar
- Outputting Page Title As Tooltip
- How to add class and span to
- Appearance > Menus
- Using categories and pages in menus
- extra tag is added in wp_nav_menu
- menu item active class for author.php
- My WordPress menu based on Twitter bootstrap creates menu-item and not page-item
- menu entries are lost
- Menu administration, how to allow special charachters
- How to avoid website url appending problem in wp site?
- Create custom page and custom menu
- Get first menu item of custom menu
- How can I modify wp_nav_menu with walker?
- menu items outside of blog
- Bought custom navigation menu from codecanyon, how to change feature.php?
- Custom menu linking to page not found
- How to insert date in topNav
- Change sub-menu css class
- How to add an tag when a menu item is a dropdown(or has a sub-menu) [duplicate]
- How to display a submenu as a popup when clicking a button?
- How do i add logo in wordpress studiopress (glam theme)?
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- how to add permalink/slug to wordpress custom link menu item
- Submenu items not working anymore
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- How to change WP menu item type?