WordPress.org

Ready to get started?Download WordPress

Forums

Add span around link in page-list (4 posts)

  1. drublic
    Member
    Posted 4 years ago #

    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

  2. Karine
    Member
    Posted 4 years ago #

    Hi,

    I have written a tutorial about this on my blog :)

  3. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    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>
  4. drublic
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic