• I’m using wp_list_pages to output the nav on a blog. However, the client wants a change to the nav links that’ll require me, for CSS styling purposes, to give each nav li its own class or id. I guess I could use what’s generated now, but it seems really messy. I also don’t want to hardcode the navs, I’d still like them to generate, but my knowledge of PHP syntax is really remedial. Basically, here’s my goal — My code now:
    <?php wp_list_pages('title_li=' ); ?>
    generates

    <li class="page_item page-item-6 current_page_item"><a href="https://mysite.com/wordpress" title="Home">Home</a></li>
    <li class="page_item page-item-8"><a href="https://mysite.com/wordpress/calendar" title="Calendar">Calendar</a></li>
    <li class="page_item page-item-250"><a href="https://mysite.com/wordpress/press" title="press">Press</a></li>

    Etc.

    What I’d like to generate is:

    <li class="home"><a href="https://mysite.com/wordpress" title="Home">Home</a></li>
    <li class="calendar"><a href="https://mysite.com/wordpress/calendar" title="Calendar">Calendar</a></li>
    <li class="press"><a href="https://mysite.com/wordpress/press" title="press">Press</a></li>

    I could also work with li IDs instead of classes. And I’d still like to use the “.current_page_item” class, so if we could keep this or find a way to generate something that’ll work the same, that’d be awesome.

    Is it possible to use PHP somewhere in my header to do this?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change wp_list_pages output to my own classes?’ is closed to new replies.