WordPress.org

Ready to get started?Download WordPress

Forums

List pages or menu without markup (6 posts)

  1. pealo86
    Member
    Posted 2 years ago #

    I'm trying to output the pages of my website or a menu but without the
    <ul> markup etc.

    I need it to be output similar to the following:

    <nav>
    	<span><a href="#">Testimonials</a></span>
    	<span><a href="#">Get in Touch</a></span>
    	<span><a href="#">Some Additional Page</a></span>
    </nav>

    But WordPress automatically wraps everything in a list. Is there a way to do this?

    I tried the 'link_before' and 'link_after' parameters with wp_nav_menuhowever it still wrapped each item with

    <li></li>
    </ul>

    [Please post code snippets between backticks or use the code button.]

  2. ChristiNi
    Member
    Posted 2 years ago #

    Hi pealo86,

    I did a little research on this and in order to remove the

      markup you would have to alter the WordPress core files which is not recommended. What are you trying to do that requires the page links to not be in a list?

      If you're trying to create a horizontal navigation bar, you can style that with CSS or even a plugin that will modify the CSS for you.

      Hope this helps!

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    IT can be done by adding a custom walker to the nav menu, you can modify the output however you like

    I don't have any sample code, I just know it's possible. Searching around for a wp_nav_menu custom walker should get you some examples

  4. Daluxe
    Member
    Posted 2 years ago #

    Why don't you just use get_pages() and style the output of each item yourself?

  5. pealo86
    Member
    Posted 2 years ago #

    Thanks for the tips.

    The custom walker looks like the best way to go however I don't quite have the time at the minute to get my head around how it works.

    I may have to just hardcode the nav into the template for now.

    For those who are wondering, I need to change the HTML output as I need / want it to be HTML5 as opposed to just a standard XHTML list.

  6. pealo86
    Member
    Posted 2 years ago #

    @Daluxe Hadn't thought of using 'get_pages()', it's proving a useful substitute!

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic