Post Pic

How to: Insert special characters between menus items

The wp_list_pages fnction is very useful, but sometimes it can be a bit frustrating, for exemple when you want to insert characters as such as “//” between menu items. Happilly, here is the solution to this problem.

To apply this hack, simply paste the following code where you want your menu to be displayed.

<?php
$char = ' \\ ';
wp_list_pages('link_before=<li>&link_after='.$char.'</li>');
?>

Found on WordPress Codex.

By the way if you're a WordPress blogger interrested in finance and investment, you should definitely read this post I wrote yesterday on cats Who Code.

8 Responses

Mar 12 2009 16:29

I didn’t tried to enter that kind of characters, but if I’ll try I’ll know how to do it. Useful!

Mar 12 2009 20:02

Wow. Simple as hell. Yet, I would’ve never thought of that. I’ll try to use it in an upcoming theme.

Mar 13 2009 15:42

Simple, yet very useful!

Mar 16 2009 23:07

Hehe, sweet one indeed. Surely not so widely used, but if you come to this problem, very useful. Thanks for sharing.

Apr 16 2009 08:44

Hello it’s working but some bug in that code

“page” word appear in the top in right side of the menu so update your code

NEW CODE

<?php $new = ‘ – ‘; wp_list_pages(‘title_li=&link_before=&link_after=’.$new.”);?>

I need other help

how can i remove last link “-”

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required