WordPress.org

Ready to get started?Download WordPress

Forums

Adding special character between [wp_list_pages] (3 posts)

  1. Aslamp
    Member
    Posted 4 years ago #

    Hello I wish to add the character "|" In between my WP pages. here is my
    Example: Home | About | Services | Contact
    current code:

    <ul class="Menu">
        &nbsp;&nbsp;&nbsp; &nbsp;
        <li<?php if ( is_home() ) { echo ' class="current_page_item"'; } ?>><a href="<?php echo get_option('home'); ?>"><span>Home</span></a>
          <?php wp_list_pages('depth=1&title_li'); ?>
    
       </ul>

    website http://www.zpirit.no/en/

  2. Len
    Member
    Posted 4 years ago #

    Hi Aslamp,

    Try replacing ...

    <?php wp_list_pages('depth=1&title_li'); ?>

    with ...

    <?php
    $char = ' | ';
    wp_list_pages('title_li=&depth=1&link_before=<li>&link_after='.$char.'</li>');
    ?>

    Be sure to backup the file first in case something goes awry.

  3. Aslamp
    Member
    Posted 4 years ago #

    Hey LenK.
    Thanks for your replay.
    I changed the code, but it messed up the menu.
    Link to Screenshot

    Any other suggestions ? :)
    Current code:

    <ul class="Menu">
         &nbsp;&nbsp;&nbsp;&nbsp;
        <li<?php if ( is_home() ) { echo ' class="current_page_item"'; } ?>><a href="<?php echo get_option('home'); ?>"><span>Home</span></a></li>
    	<?php
    $char = ' | ';
    wp_list_pages('title_li=&depth=1&link_before=<li>&link_after='.$char.'</li>');
     ?> </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic