[wp-trac] [WordPress Trac] #46042: wp_nav_menu always returns a container

WordPress Trac noreply at wordpress.org
Sat Jan 19 19:46:16 UTC 2019


#46042: wp_nav_menu always returns a container
--------------------------+------------------------------
 Reporter:  thememason    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Menus         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by thememason):

 has_nav_menu() is only useful if you do not intend to use the fallback
 function wp_page_menu called by wp_nav_menu. The problem is that if a
 website only uses posts and there are no actual pages, it returns an empty
 <div>.

 Right now the only solution I've found is to use strpos to determine if an
 <li> item exists in what wp_nav_menu returns. This is more of a hack for
 now. Here's my theme file where you can see the code:
 https://themes.trac.wordpress.org/browser/gavel/1.0.9/header.php

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46042#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list