0

我在菜单中编写了显示 acf 的函数。我只需要在深度 [0] 中显示。所有工作。但我仍然要注意:
注意:未定义索引:nav_menu_item_depth

这是我的代码:

add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types($choices)
{
    $choices['Menu']['menu_level'] = 'Livello Menu';
    return $choices;
}

add_filter('acf/location/rule_values/menu_level', 'acf_location_rule_values_level');

function acf_location_rule_values_level($choices)
{
    $choices[0] = '0';
    $choices[1] = '1';

    return $choices;
}

add_filter('acf/location/rule_match/menu_level', 'acf_location_rule_match_level', 10, 4);
function acf_location_rule_match_level($match, $rule, $options, $field_group)
{
  global $current_screen;
    if ($current_screen->id == 'nav-menus') {
        if ($rule ['operator'] == "==") {
            $match = ($options['nav_menu_item_depth'] == $rule['value']); // <-- Problem is here
        }
    }
    return $match;
}

有些可以帮助我理解吗?谢谢

4

0 回答 0