wordpress 警告:Worpress中未定义的数组键5081

llycmphe  于 2022-11-22  发布在  WordPress
关注(0)|答案(2)|浏览(168)

警告:第210行的/customers/c/c/a/ www.example.com中有未定义的数组键5081bhcjobs.com/httpd.www/wp-includes/nav-menu-template.php

// Set up the $menu_item variables.
    _wp_menu_item_classes_by_context( $menu_items );

    $sorted_menu_items        = array();
    $menu_items_tree          = array();
    $menu_items_with_children = array();
    foreach ( (array) $menu_items as $menu_item ) {
        $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
        $menu_items_tree[ $menu_item->ID ]           = $menu_item->menu_item_parent;
        if ( $menu_item->menu_item_parent ) {
            $menu_items_with_children[ $menu_item->menu_item_parent ] = 1;
        }

        // Calculate the depth of each menu item with children
        foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
            $menu_item_parent = $menu_items_tree[ $menu_item_key ];
            while ( $menu_item_parent ) {
                $menu_item_depth  = $menu_item_depth + 1;
                $menu_item_parent = $menu_items_tree[ $menu_item_parent ];
            }
        }
    }

请帮助解决此问题
我需要帮助来解决此问题

aiazj4mn

aiazj4mn1#

我的网站也遇到过类似的问题。我创建了一个新的菜单,并将所有菜单项移到新菜单中,解决了这个问题。更新wordpress或主题似乎无效。

93ze6v8z

93ze6v8z2#

试试这个...

// Set up the $menu_item variables.
_wp_menu_item_classes_by_context( $menu_items );

$sorted_menu_items        = array();
$menu_items_tree          = array();
$menu_items_with_children = array();
foreach ( (array) $menu_items as $menu_item ) {
    $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
    $menu_items_tree[ $menu_item->ID ]           = $menu_item->menu_item_parent;
    if ( $menu_item->menu_item_parent ) {
        $menu_items_with_children[ $menu_item->menu_item_parent ] = 1;
    }
}

// Calculate the depth of each menu item with children
foreach ( $menu_items_with_children as $menu_item_key => &$menu_item_depth ) {
    $menu_item_parent = $menu_items_tree[ $menu_item_key ];
    while ( $menu_item_parent ) {
        $menu_item_depth  = $menu_item_depth + 1;
        $menu_item_parent = $menu_items_tree[ $menu_item_parent ];
    }
}

希望对你有帮助。

相关问题