I’m trying to customize the default WordPress menus. Added this to my functions.php file and it makes my menus disappear. What is wrong?

function custom_novice_menu($args) {
    $defaults = array(
        'container' => 'div'
    );
}

add_action('wp_nav_menu', 'custom_novice_menu');

Here is some documentation on wp_nav_menu()

1 Answer
1

I don’t think there’s wp_nav_menu action. Perhaps you want the wp_nav_menu filter (doc)?

function custom_novice_menu($args) {
    if( 'primary' == $args['theme_location'] ) // only apply to the right menu
    {
        $args['container'] = 'div';
    }

    return $args;
}

add_filter('wp_nav_menu', 'custom_novice_menu');

Leave a Reply

Your email address will not be published. Required fields are marked *