• Resolved jonniboo

    (@jonniboo)


    Hi there,

    Can anyone tell me how to add span tags to the resulting list items from the wp_list_pages function?

    I’m trying to add rounded corners to the backround images of a navigation bar using CSS2 and need span tags for this purpose.

    Thanks,
    John

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you want the span tags inside the link tags..
    ie.

    <a><span></span></a>

    ..then you can use the link_before and link_after parameters..
    http://codex.wordpress.org/Template_Tags/wp_list_pages

    Else you’ll need to store the data( echo = 0 ) and do a string replace.. like so..
    ie.

    <?php
    $pagetest = wp_list_pages( 'echo=0&title_li=' );
    $pagetest = str_replace( '><a href' , '><span><a href' , $pagetest );
    $pagetest = str_replace( '</a></li>' , '</a></span></li>' , $pagetest );
    echo( $pagetest );
    ?>

    Thread Starter jonniboo

    (@jonniboo)

    Thanks for you reply,
    I’m a novice with PHP..

    Any chance you can show an example of using the link_before and link_after parameters?

    Thanks,
    John

    Sure..

    <ul>
    <?php wp_list_pages('link_before=<span>&link_after=</span>'); ?>
    </ul>

    Thread Starter jonniboo

    (@jonniboo)

    That’s great,

    thanks a lot mate.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘adding <span> tags to wp_list_pages function’ is closed to new replies.