Insert Special Characters Into Horizontal Menu
Hardcoding a navigation menu to display a list of pages is not necessary thanks to the wp_list_pages() template tag which automatically generates the list for you. Perusing the Codex we see this template tag accepts numerous parameters to modify the output. A standard use of this tag in a horizontal navigation menu might look like this...
<?php wp_list_pages('title_li='); ?>
The parameter title_li sets the text and style of the list's heading. The default reverts to 'Pages' but if left blank as above nothing is displayed. Thus using wp_list_pages with the parameter title_li= will render a list of pages with no heading.
What if we wanted to insert a special character such as ' | ' or ' // ' between the individual menu items? Do we then have to manually code our navigation menu? Not at all. All we need to do is make a slight modification. Take a look at the code below...
<?php
$char = ' // ';
wp_list_pages('link_before=<li>&link_after='.$char.'</li>');
?>
What this will do is generate a list of pages with // between each menu item. Cool, yes? How do we use this with the title_li parameter? Let's throw a couple of things into the mix so you better understand the string. Let's use the parameters title_li and exclude with the above code. It would now look like...
<?php
$char = ' // ';
wp_list_pages('title_li=&exclude=1050,1255&link_before=<li>&link_after='.$char.'</li>');
?>
What this will do is generate a list of pages, with no heading and omitting the pages with the numerical ID of 1050 and 1255 while inserting // between each menu item. You can use as many parameters as you want - just be sure to preface each one with &. Let's see a screen shot of what it looks like. (click image to enlarge)


