• Resolved dunkkan

    (@dunkkan)


    Hello guys,

    I’m using in my template wp_list_pages to get a pertinent list, styled as a line with CSS (display:inline), and adding, after each item, this html sign |.

    My tag in detail :

    <ul>
         <?php wp_list_pages('title_li=&amp;;link_after= | &amp;;include=7,8,9'); ?>
    </ul>

    But the last link is affected, too :

    Contact | People | Twitter |

    I need to clear it in the last item … does anybody knows the how to ?

    Thanks very much,

Viewing 1 replies (of 1 total)
  • Thread Starter dunkkan

    (@dunkkan)

    I did it with JQuery, as I use it for everything.

    I’m sure there are better ways, but, by now :

    1. Download JQuery (a minified version is ok)
    2. Place it in your theme’s folder, for instance in a folder called “js”
    3. Call it in your <head> : just like <script type="text/javascript" src="https://mywebsite/blog/theme/js/jquery.js"></script>
    4. The new WP tag :
    <ul><?php wp_list_pages('link_after=<span class="clearstick"> | </span>'); ?></ul>

    Keep an eye to the span with the class we are adding there. JQuery will target them to apply the changes we want.

    Finally in the footer, before the </body> closing tag …

    <script>
      $(document).ready(function(){
        $("ul li a:last .clearstick").text("");
      });
    </script>

    Those are the instruction JQuery needed. In english would be : find me an unordered list which have a last item with the class .clearstick, then replace whatever it was inside with an empty space.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_list_pages and html’ is closed to new replies.