ThemeShaper Forums » Thematic

[closed]

Menu stuck

(6 posts)
  • Started 1 year ago by bogh
  • Latest reply from bogh
  • This topic is resolved

Tags:

  1. bogh
    Member

    I have added this to my child theme:

    function menu_args( $args ) {
    $args = array(
    	'menu_class' => 'nav sf-menu',
    	'container_class' => 'menu',
    	'walker' => new Custom_Walker
    	);
    return $args;
    }
    add_filter( 'thematic_nav_menu_args', 'menu_args' );

    And now I can use just only the first menu that I have created, if I change the primary menu nothing happens on the website.
    What could be the issue? Is something wrong with the above function or the filter?

    Thank you.

    Posted 1 year ago #
  2. if you change the menu nothing happens. please explain further.

    Posted 1 year ago #
  3. bogh
    Member

    Ok.
    So, I have created 2 menus: "Menu One" & "Menu Two". "Menu One" was the first created and the first I have used.
    Now I want my "Primary Menu" to be "Menu Two", so I have changed it in the backend. But on the website I still see "Menu One".

    If I remove that filter & the function I am able to change between "Menu One" & "Menu Two". So I have considered that function to be the cause for this issue.

    Let me know if is still unclear.

    Posted 1 year ago #
  4. no that is clear, thanks. i have not experienced this. i think i have an idea, but will try to test it out later.

    Posted 1 year ago #
  5. ok, it is as i thought.... when you set $args = array() you effectively overwrite the original $args that is being passed to your function. you eliminate everything, including the super important 'theme_location' parameter. without that wp_nav_menu() (the function that is using these args) probably has no idea what to do. you need to modify the array and not reset it. you can do that one of 2 ways:

    function menu_args( $args ) {
    	$newargs = array(
    		'menu_class' => 'nav sf-menu',
    		'container_class' => 'menu',
    		'walker' => new Custom_Walker
    		);
    	return wp_parse_args($newargs, $args);
    }
    add_filter( 'thematic_nav_menu_args', 'menu_args' );

    or

    function menu_args( $args ) {
    	$args['menu_class'] = 'nav sf-menu';
    	$args['container_class'] = 'menu';
    	$args['walker'] = new Custom_Walker;
    
    	return $args;
    }
    add_filter( 'thematic_nav_menu_args', 'menu_args' );

    this solves the problem for me here locally.

    Posted 1 year ago #
  6. bogh
    Member

    Thanks a lot. This solved it.
    Both solutions are working.
    The only difference I see for now is that the 1st solution seems to react faster on WP 3.4 RC1, when you are in Customize mode, and change the between menus.

    Thanks again.
    Have a good day!

    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.