• Hi,

    does anyone know how to teak the “wp_list_pages” output to include an “after” parameter (without hacking the WP install, directly). I have a list output from “wp_list_pages”, and I have my css creating a horizontal menu, here is the current output:

    <li class="page_item"><a href="/biography/" title="Bio">Biography</a></li>
    <li class="page_item"><a href="/contact/" title="Contact">Contact</a></li>
    <li class="page_item"><a href="/links/" title="Links">Links</a></li>
    <li class="page_item"><a href="/search/" title="Search">Search</a></li>

    producing what looks like this:

    Bio Contact Links Search

    Since the menu is horizontal, I’d like to add a comma at the end of each link in the menu. But I can’t (for the life of me) figure out how to add the end comma. This is what I’d like the output to look like:


    <li class="page_item"><a href="/biography/" title="Bio">Biography</a>,</li>
    <li class="page_item"><a href="/contact/" title="Contact">Contact</a>,</li>
    <li class="page_item"><a href="/links/" title="Links">Links</a>,</li>
    <li class="page_item"><a href="/search/" title="Search">Search</a>,</li>

    producing what looks like this:

    Bio, News, Links, Search,

    It looks to me as if the only way to do this is to add the commas using the “li” selector to add the comma as generated content in the css. but this presents a problem in certain browsers. I’d like avoid using generated content and to avoid hacking my WP install.

    any takers?

    bones points for anyone who can do the exact same for the “wp_list_cats” output

Viewing 2 replies - 1 through 2 (of 2 total)
  • i’ve just done a similar tweak to wp_list_pages. near the bottom of template-functions-post.php there’s the following line:

    $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';

    in your situation i think you just need to add a space and comma after the </a>. i hope that helps.

    Thread Starter edfladung

    (@edfladung)

    Hey Hristov,

    I’m trying to avoid hacking the wp install. “too many threads to keep in old duder’s head”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tweaking “wp_list_pages” & “wp_list_cats” output’ is closed to new replies.