Viewing 4 replies - 1 through 4 (of 4 total)
  • Not without writing your own page listing function.

    Thread Starter kelune

    (@kelune)

    Yes, that is exactly where I’m trying to go.

    Then I’d suggest starting with get_pages.

    Thread Starter kelune

    (@kelune)

    Alright, maybe I’m not being specific enough:

    I have a custom nav that sets a class for each link that is the same as the page title:
    <li id="home"><a href="home">Home</a></li>

    Additionally, it sets the active class for the parent if you are on any child pages:

    <li<?php if ( is_page( 'we-do-well-when-our-clients-do-great' ) || '3' == $post->post_parent) { echo ' class="active"'; } ?> id="home"><a href="home">Home</a></li>

    In addition to THAT, it also adds another language via qtranslate:

    <li<?php if ( is_page( 'home' ) || '3' == $post->post_parent) { echo ' class="active"'; } ?> id="home"><a href="home"><?php if(qtrans_getLanguage()=='en'): ?>Home<?php endif; ?><?php if(qtrans_getLanguage()=='es'): ?>Inicio<?php endif; ?></a></li>

    I’d love to use wp_list_pages for this with a nice string of arrays, but I can only get so far as <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=&exclude=45'); ?> with an additional function to get the top parent page id in order to turn that link as active.

    What I’d like to do is to create a function that replaces
    <li class="page_item page-item-3 current_page_item"><a href="home" title="home">home</a> with something more dynamic, so that the classes of each link would not have to be edited if page-ids change. For instance: <li class="home active"><a href="home" title="home">home</a>

    I’ve found ways to call the current page name, but was wondering how to grab that page name from somewhere else so that I could turn all of this into a much easier to use function. I know enough to mesh things together to get an output that I want, but not enough to create something completely from scratch. I’m sorry if I’m not seeing anything related to what I’m looking for with get_pages or wp_list_pages. If you or anyone else could help point me in a more clearer direction to get the title of a listed parent page into a class, it would be a great help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_pages changing class 'page-item-#' to page name?’ is closed to new replies.