Customising wp_list_pages, but only for top-level pages
-
Hi all,
Just a question here – I want to customise the wp_list_pages in my blog to insert a list item between each of the main headings. The end result would be something like this:
<ul id="nav-menu"> <li class="nav-menu-divider"></li> <li><a href="">Gallery</a> <ul> <li><a href="">Submenu-1</a></li> <li><a href="">Submenu-2</a></li> <li><a href="">Submenu-3</a> <ul> <li><a href="">submenu-3.1</a></li> </ul> </li> <li><a href="">Submenu-4</a> <ul> <li><a href="">Submenu-4.1</a></li> </ul> </li> </ul> </li> <li class="nav-menu-divider"></li> <li><a href="">About</a></li> <li class="nav-menu-divider"></li> <li><a href="">Contact</a></li> </ul>
I’ve looked at using str_replace in a tutorial at https://www.wantusiak.com/wordpress/wordpress-how-to-style-wp_list_pages , but figured that doing that would affect all posts including the nested ul’s, and not the main listing.
Can anyone offer any advice on getting a str_replace to affect just the top level items? All I need to do is insert the li with the nav-menu-divider class before each.
Note I’m a bit of a n00b when it comes to php, so be gentle ??
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Customising wp_list_pages, but only for top-level pages’ is closed to new replies.