Support » Themes and Templates » List pages or menu without markup
5 years, 1 month 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:
<span><a href="#">Get in Touch</a></span>
<span><a href="#">Some Additional Page</a></span>
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
[Please post code snippets between backticks or use the code button.]
I did a little research on this and in order to remove the
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!
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
Why don’t you just use get_pages() and style the output of each item yourself?
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.
@daluxe Hadn’t thought of using ‘get_pages()’, it’s proving a useful substitute!