Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In relation to question posted here, is it possible to have an output to have something like this instead? where class="parent" is applied to the hyperlink?

<ul>
    <li><a href="#">Page 1</a></li>
    <li><a class="parent" href="#">Page with Subpages</a>
        <ul class="children">
            <li><a class="parent" href="#">Page with another subpage</a>
                <ul class="children">
                    <li><a href="#">subsubpage</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li><a href="#">Page 3</a></li>
    <li><a href="#">Page 4</a></li>
</ul>

the function below of TheDeadMedic works well for lists:

function add_parent_class( $css_class, $page, $depth, $args )
{
    if ( ! empty( $args['has_children'] ) )
        $css_class[] = 'parent';
    return $css_class;
}
add_filter( 'page_css_class', 'add_parent_class', 10, 4 );

is it possible to use a similar function to target hyperlinks instead of the lists?

share|improve this question

1 Answer 1

According to this thread, you can add a custom Walker class to your wp_list_pages() call. It looks like that's the way to go, since wp_list_pages() prints or returns a string.

If you set $args['echo'] to false, you can do some string manipulation before you echo() it, but it seems to me that the Walker solution is probably the way to go.

Unfortunately the Walker documentation looks a little thin.

share|improve this answer
    
thanks, pat. it sure is hard with very little documentation /reference around. i will give the walker approach a try. –  Pabile Mar 13 '13 at 7:38
    
Here's a Walker documentation page with a bit more content: codex.wordpress.org/Function_Reference/Walker_Class . Good luck! –  Pat J Mar 13 '13 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.