Support » Themes and Templates » Add span around link in page-list

  • Hey guys!

    Oh man, I searched nearly whole Google for getting my problem fixed, but I didn’t find any answer.

    I need to wrap a span-tag around the links in the pagetree. I get the links with wp_list_pages(); I put them in a list:

      <li><a href="... </a></li>

    This works without any problem. But what I need is:

      <li><span><a href="... </a></span></li>

    I know that I can do stuff like wrapping a span around the linktext with before and after but I need it this way.

    Does anyone know an answer?

    Thanks for any answer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    I have written a tutorial about this on my blog 🙂



    Forum Moderator

    try using:

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

    ka-ri-ne, this is not what I need but thanks.

    akchymyth, thank you. This is a quite nice solution. Maybe a kind of workaround. But easy and simple.
    Thank you very much. 🙂 It works nicely.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add span around link in page-list’ is closed to new replies.