Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to add a special character to display a » alongside each menu item in Wordpress.

So for example

About us » Contact us » And so on...

Here's my code

      <li><?php echo $children; echo '»'; ?></li>

I expected this would do the job, but it just puts the » below the list.

Here's the full code

      <?php
      if($post->post_parent) {
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $titlenamer = get_the_title($post->post_parent);
      }

      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>

      <h2 class="left_title">
        <?php echo $titlenamer ?>
      </h2>
      <ul class="left_body">

        <li><?php echo $children; echo '»'; ?></li>

      </ul>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can do this in three ways:

1) Use before and after arguments in wp_nav_menu

2) Write a custom walker

3) Use CSS :before or :after pseudo classes to add the character. The character must be in escaped unicode, e.g.:

li:after {
 content: '\00BB';
 padding-right: 5px;
}

There is more in a similar StackExchange answer

share|improve this answer
    
Thanks Pieter for the edit. –  Matt Radford May 19 at 10:01
    
great answer -thank you –  hyp0thetical May 19 at 14:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.