Add Breaks to WP Nav Menu (2 posts)

  1. cpcdev84
    Posted 2 years ago #

    Hi after, searching for an answer on how to remove
    ul and li tags from a WP NAV MENU, I found this solution:

    $foot_nav = wp_nav_menu( array( 'container' => '', 'echo' => '0', 'theme_location' => 'registrations' ) );
    $foot_nav2 = preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '', $foot_nav );
    $foot_nav2 = preg_replace( array( '#<li[^>]*>#', '#</li>$#' ), '', $foot_nav2 );
    echo $foot_nav2;

    My only issue with this is I would like to add a BREAK after each link so the nav looks as follows:

    Link 1
    Link 2
    Link 3

    ... how can I accomplish this? I tried to PM the OP but no way of doing so.

    Thanks for the help

  2. kjodle
    Posted 2 years ago #

    You can accomplish this with custom CSS, rather than tearing into theme files.

    Depending on how your theme sets things up, you can accomplish it something like this:

    #nav > ul > li {
       padding: 12px 0;

    You'll need to take a look at your source code to see how your theme actually sets it up.

    Link to your site?

Topic Closed

This topic has been closed to new replies.

About this Topic