• just_bri

    (@just_bri)


    Anyway, I’m creating a website (theme used: SimpleMag), and its menu looks like this:
    Home | About | FAQ | Requests | Audio | Video | Forum | Contact

    But I want to add line breaks so it looks like this instead:
    Home | About | FAQ | Requests
    Audio | Video | Forum | Contact

    When 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;
                    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter just_bri

    (@just_bri)

    Hi yet again.

    I’ve done some more research…and I think there might be another way to do this. Is it possible to use the following jQuery code anywhere?

    <script>
    $( ".menu-item-4" ).after( "<br/><br/>" );
    </script>

    Did I type it correctly? I tried adding that to the header.php file, but it’s not working.

    And should I edit anything else in the header file? I saw some websites mention this new line of code; maybe I need to add it too?
    <?php wp_enqueue_script('jquery'); ?>

    Thanks again. ??

Viewing 1 replies (of 1 total)
  • The topic ‘[PHP NavMenu] Add Line Break to Certain URL in Menu?’ is closed to new replies.