Archived topic
Navigation error after migration
4 replies · Started by Brand on May 1, 2019
Hi Tom & Co.
After moving a recent site, i get prompted an error;
Warning: Invalid argument supplied for foreach() in /******/public_html/wp-content/themes/generatepress/inc/structure/navigation.php on line 223
Can't see what caused the error or find out how to resolve it.
We have the site running on our own servers, in exact same state, but without any errors.
Can you see what's up?
Site running php 7.1.28
Ok i found the file causing the error - but not why it doesn't work on the new site, but does on the old.
The file contains the following, to setup a custom mega-menu:
add_filter('wp_nav_menu_objects', 'megamenu_wp_nav_menu_objects', 10, 2);
function megamenu_wp_nav_menu_objects( $items, $args ) {
// loop
foreach( $items as $item ) {
// vars
$icon = get_field('mega_icon', $item);
$description = get_field('mega_description', $item);
// append icon
if( $icon ) {
$item->title = '<div class="mega-menu-icon-container"><div class="inner-text"><span class="title">' . $item->title .'</span>';
$item->title .= '<span class="description">' . $description .'</span>';
$item->title .= '</div>';
$item->title .= '<div class="inner-image"><img src="' . $icon['url'] .'"></div>';
$item->title .= '</div>';
$item->classes = 'mega-menu-icon';
}
}
// return
return $items;
}
What if you remove/comment out this line?: $item->classes = 'mega-menu-icon';
Tried that, and that do "resolve" the problem.
But i need that class, for styling the mega-menu elements.
Where'd you get that code from?
I wonder if this would fix it?:
$item->classes[] = 'mega-menu-icon';