ThemeShaper Forums » Thematic


Filter menu items to replace 'separator' items with blank li element

(6 posts)
  • Started 9 years ago by chrizbo
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. chrizbo

    Hi everyone.

    I have created a menu via admin -> Appearance -> Menus and wanted to filter it. The reason is that I would like to have separators (spacer) that is dynamically placed in the menu admin tools.

    These menu items will be labeled something like 'separator' (entering blank in admin just removes the menu item) and I wanted to replace those with a 'li' element that has a space and no link.

    I tried doing something like this, but no luck:

    function filter_separators($menu) {
    	return preg_replace('/<a href=\"#\">separator<\/a>/', '&nbsp;', $menu);



    Posted 9 years ago #
  2. see the sticky on menus. i have a section on using a "custom walker" function. that's my guess for what you need.

    Posted 9 years ago #
  3. chrizbo

    Awesome, that is just what I am looking for. I just look at the title and if it matches a keyword I replace it with an empty LI.

    Can the 'walker' concept also allow me to add things at the beginning and end of a nav menu? It doesn't look like I am able to based on the documentation I was able to find...


    Posted 9 years ago #
  4. chrizbo

    I think I figured it out: I am going to just set 'container' to NULL and wrap it with my own UL and any before or after links I want.


    Posted 9 years ago #
  5. marknolan

    how would i go about adding a | or a - between the top level menu items?
    i'm a bit lost...

    Posted 9 years ago #
  6. any markup changes to the menu must be done w/ a custom walker. see the sticky. i don't have a lot of experience w/ it though and didn't do anything even remotely complicated in my example. it is one of the more obscure and not-so-well documented parts of WP.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.