Forums
Home / Themes and Templates / wp_page_menu custom classes
(@sbjluke)
12 years, 4 months ago
Using the <?php wp_page_menu( 'sort_column=menu_order' ); ?> code, the browser returns <div class="menu"><ul><li class="page_item page-item-711 current_page_item"><a href="http://localhost/wordpress/" title="Home">Home</a></li><li class="page_item page-item-713"><a href="http://localhost/wordpress/?page_id=713" title="Blog">Blog</a></li><li class="page_item page-item-707"><a href="http://localhost/wordpress/?page_id=707" title="About">About</a></li><li class="page_item page-item-23"><a href="http://localhost/wordpress/?page_id=23" title="Contact Us">Contact Us</a></li></ul></div>
<?php wp_page_menu( 'sort_column=menu_order' ); ?>
<div class="menu"><ul><li class="page_item page-item-711 current_page_item"><a href="http://localhost/wordpress/" title="Home">Home</a></li><li class="page_item page-item-713"><a href="http://localhost/wordpress/?page_id=713" title="Blog">Blog</a></li><li class="page_item page-item-707"><a href="http://localhost/wordpress/?page_id=707" title="About">About</a></li><li class="page_item page-item-23"><a href="http://localhost/wordpress/?page_id=23" title="Contact Us">Contact Us</a></li></ul></div>
I’m wondering if I can define my own class name instead of the long page_item page-item-713 that it gives each li.
page_item page-item-713
Thanks!
(@esmi)
Not when using wp_page_menu(), no. You’d need to build your own page listing function for that.
Great, Thanks! Should probably learn how to make custom functions anyhow…