Posted: May 28th, 2010 By: Devin Walker
WordPress makes it very easy to dynamically create menus from pages and categories with the use of the function wp_list_pages() and wp_list_cats()... but what if you want to have separators in your menus? Here's a bit of code that will do just that:
wp_list_pages Separators
$args = array( 'sort_column' => 'menu_order', 'title_li' => '', 'depth' => '1', 'echo' => 0 ); $separator = ' | '; $pattern = '/(<\\/a>).*?(<\\/li>).*?(<li)/is'; $replace = '</a>' . $separator . '</li><li'; $subnav = preg_replace($pattern,$replace,wp_list_pages($args)); echo $subnav;
Please note: I got this code from Rares Comes (very nice lavalamp menu there)
Related posts:
- WordPress Heirarchical Sidebar Page Menus Let's say you want to show a hierarchical sidebar menu that displays a listing of current subpages. This is easy enough, but let's say that you have a top menu that shows all top-level pages. Once you click on a top level page from that menu it will take you there and in the sidebar [...]...
- WordPress List Subpages Even if On Subpage I'm building a new site and the navigation on it requires me to use a different bit of code for parent and child pages. I thought I'd share the code for those out there building a similar navigation. Here's a handy bit of code that you can use to display all subpages on a subpage. [...]...
- GoDaddy WordPress Sites Infected by HolasionWeb Malicious Code Have you gotten calls from your clients hosted on GoDaddy about their WordPress site's being 'hacked'? Or perhaps this happened to you yourself. It seems there's a new report of thousands of WordPress sites being infected by malicious javascript inserted on their WordPress website. It's not everyday that WordPress gets 'hacked' by something/one. Today one [...]...
- How to Remove Unnecessary Lines Between Code I get really annoyed when there's unnecessary lines in code that I'm editing. If you're like me you may want to know a useful way to take them out. Easily. Well check this out, here's we will be using Dreamweaver CS4's find-and-Replace tool to remove unnecessary blank lines between your code. This is particularly helpful [...]...
- WordPress Lavalamp Navigation Tutorial Lavalamp is an awesome jQuery plug-in that makes really cool effects for WordPress-based menus and navigation links, and as a bonus it is very lightweight. It can be a bit tricky to implement in WordPress, but after you read this tutorial hopefully you'll be implementing it with ease. Follow along and let's get your site's [...]...
-
Matt Slocum
-
Matt Slocum






