[PHP NavMenu] Add Line Break to Certain URL in Menu?
-
Anyway, I’m creating a website (theme used: SimpleMag), and its menu looks like this:
Home | About | FAQ | Requests | Audio | Video | Forum | ContactBut I want to add line breaks so it looks like this instead:
Home | About | FAQ | Requests
Audio | Video | Forum | ContactWhen I manually edit the page (ie, save it to my computer + type <.br/><.br/>), it works fine:
... <li id="menu-item-3" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="#">FAQ</a></li> <li id="menu-item-4" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="#">Requests</a></li> <!--MENU SEPARATOR--> <br/><br/> <!--MENU SEPARATOR--> <li id="menu-item-5" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="#">Audio</a></li> <li id="menu-item-6" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="#">Video</a></li> ...
BUT…I can’t actually do this with the live site. All HTML code is generated via PHP docs, specifically the header.php file. So I need to use PHP in that specific file, but I don’t have experience in that language at all. ??
As you can see in the above code, each menu item/link is contained in an <.li> tag that has its own ID. So I’m guessing that I’d need to use something like this pseudo PHP code?:
Pseudo PHP Code I’ll Probably Need:
if [id=”menu-item-4″]:
echo ‘[menu-item-4]’ + “\n\n”Below is the actual code from header.php, that controls the main menu area. If anyone could tell me (1) what code to use, and (2) where to put it, I’d greatly appreciate it. Thanks in advance!!
<?php // Main Menu if ( $ti_option['site_main_menu'] == true ): if ( has_nav_menu( 'main_menu' ) ) : echo '<div class="no-print animated main-menu-container">'; if ( $ti_option['site_fixed_menu'] == '3' && $ti_option['site_main_menu'] == true ): echo '<div class="main-menu-fixed">'; endif; echo '<nav class="wrapper main-menu" role="navigation" itemscope="itemscope" itemtype="https://schema.org/SiteNavigationElement">'; wp_nav_menu( array( 'theme_location' => 'main_menu', 'container' => false, 'menu_id' => 'main-nav', 'depth' => 3, 'fallback_cb' => false, 'walker' => new TI_Menu() )); echo '</nav>'; if ( $ti_option['site_fixed_menu'] == '3' && $ti_option['site_main_menu'] == true ): echo '</div>'; endif; echo '</div>'; else: echo '<div class="message warning"><i class="icomoon-warning-sign"></i>' . __( 'Define your site main menu', 'themetext' ) . '</div>'; endif; endif; ?>
- The topic ‘[PHP NavMenu] Add Line Break to Certain URL in Menu?’ is closed to new replies.