Support

Account

Home Forums Front-end Issues wp_nav_menu: span and a tags

Helping

wp_nav_menu: span and a tags

  • Hello,

    I am creating a nav menu in WordPress using ACF and can’t get my span and a tags recognised in the following PHP array:

    <?php
    	wp_nav_menu (
    		array(
    							                    
    		'menu' => 'top_menu',
    		'menu_id' => 'menu-primary-menu, menu-item-167, menu-item-168, menu-item-169, menu-item-170, menu-item-171, menu-item-172, menu-item-173, menu-item-174, menu-item-175',
    		'container' => 'ul, li, span, a',
    		'menu_class' => 'menu, menu-item, menu-item-type-post_type, menu-item-object-page, menu-item-has-children, menu-item-167, menu-item-168, menu-item-169, menu-item-170, menu-item-171, menu-item-172, menu-item-173, menu-item-174, menu-item-175, expand, sub-menu',
    	)
    );?>

    This is part of the mark-up context:

    <a href="#" class="footer-link">Events</a>
    <span  class="expand" role="button" tabindex="0"></span>

    It’s recognising the ‘ul’ and ‘li’ classes but not ‘span’ nor ‘a’. Does anyone know what I am missing? Does anyone know what I am missing? Any advice would help.

    Thanks!

    Franz

  • This has nothing to do with ACF, wp_nav_menu() is a native WP function, and according to the documentation, menu_id must be a string; however, an ID cannot have multiple comma separated values.

    Likewise, container must be a string consisting of the (single) element name with which you want to wrap the whole menu. What you have there doesn’t make any sense.

    And also likewise menu_class must be a string that contains class names as they would be put in the HTML, i. e. space separated, not comma separated. And these class names would be put on the <ul> that forms the menu list, as explained in the documentation, not on any single list item or whatever else is inside.

    What exactly are you trying to do?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘wp_nav_menu: span and a tags’ is closed to new replies.