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:

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

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

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

    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.
    drublic

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

    I have written a tutorial about this on my blog 🙂

    Michael

    (@alchymyth)

    Forum Moderator

    try using:

    <ul>
      <?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; ?>
    </ul>

    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.

    #resolved

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