You just need the third argument $args
, of which one of it’s properties is theme_location
:
function wpse_218377_nav_menu_css_class( $classes, $item, $args ) {
if ( ! empty( $args->theme_location ) && $args->theme_location === 'custom-menu' ) {
$classes[] = 'footer--menu-item';
}
// ALWAYS return, not from inside the if
return $classes;
}
add_filter( 'nav_menu_css_class' , 'wpse_218377_nav_menu_css_class' , 10, 3 );