ThemeShaper Forums » Thematic

[closed]

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

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

    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);
    }
    add_filter('wp_page_menu','filter_separators');

    Thanks.

    chrizbo

    Posted 8 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 8 years ago #
  3. chrizbo
    Member

    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...

    Thanks.

    Posted 8 years ago #
  4. chrizbo
    Member

    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.

    Thanks!

    Posted 8 years ago #
  5. marknolan
    Member

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

    Posted 8 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 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.