Jump to content
Guido

custom menu class

Recommended Posts

Guido    1
Guido

Hi,

 

i want to change the class which is given to a menu by default. I think it is part of wp_nav_menu - but i dont know where to find it in pagelines. Anyway i would prefer to make the change in the function.php (if possible?)

 

I need it for a custom WP menu in the sidebar - now the html appears like this:

<div class="widget-pad">   
     <div class="menu-test-container">
           <ul id="menu-test" class="menu">
                ....

 

 

I want to change it into that:

<div class="widget-pad">
    <div class="menu-test-container">
          <ul id="menu-test" class="custom">
                ....

 

 

Can this class be changed in the functions.php?

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

Hi,

 

What you're referring to is the standard Wordpress Custom Menu widget, when you name your menu, that name is added as a class to that widget, see my images below for an example.

 

1. http://d.pr/i/cFPH

2. http://d.pr/i/Cpu9

3. http://d.pr/i/lcdA

 

As you can see the HTML looks like this:

<li id="nav_menu-2" class="widget_nav_menu widget fix">
<div class="widget-pad">
<h3 class="widget-title">Menu</h3>
<div class="menu-this-is-a-menu-container">
...

If this suggestion isn't what you're looking for then you will need to ask this question on the Wordpress support forums, as this is a Wordpress widget and not related to PageLines.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Guido    1
Guido

Your suggestions lead to aply a class to single menu-items. I want to apply custom css to a the entire ul. Therefore I changed the default wp class name in the nav-menu-template.php and it works fine.
I replaced 'menu' with 'nav nav-tabs nav stacked' and pagelines applies the bootstrap design to the standard Wordpress Widget Menu, which is a big deal for me.

 

But i need to get it into the functions.php...  and yes, you are right - thats a Wordpress question at least. ;-)

Share this post


Link to post
Share on other sites
Rob    547
Rob

Hi,

 

What do you need to get into functions.php? Couldn't you use the functions.php found in the PageLines Customize plugin or in a child theme?


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Guido    1
Guido

There is a snippet in the nav-menu-template.php on line 136:

 

function wp_nav_menu( $args = array() ) {
    static $menu_id_slugs = array();

    $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'nav nav-tabs nav-stacked', 'menu_id' => '',
    'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    'depth' => 0, 'walker' => '', 'theme_location' => '' );

 

 

I replaced the default Wordpress menu class to a class provided by bootstrap:

 

'nav nav-tabs nav-stacked'

 

Now i want to move this code into the functions.php to make it update save.

Share this post


Link to post
Share on other sites
Simon    247
Simon

From the docs at: http://codex.wordpress.org/Function_Reference/wp_nav_menu

 

you can use the filter wp_nav_menu_args

 

 


 

function my_wp_nav_menu_args( $args = '' )
{
	$args['container'] = false;
	return $args;
} // function

add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );

and change it to do what you want

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×