How to target specific wp_nav_menu in function?

前端 未结 2 1351
夕颜
夕颜 2021-01-16 06:38

I am adding a specific class on my wp_nav_menu via function.php but I am not able to target a specific menu: This is what I got

function add_menuclass_active         


        
2条回答
  •  感情败类
    2021-01-16 07:39

    Theme location is stored in the nav menu arguments, you need to add it in your function parameters:

    function add_menuclass_active( $nav_menu, $args ) {
        if( $args->theme_location == 'CUSTOM MENU' )
            return preg_replace( '/

提交回复
热议问题