• Resolved andom75

    (@andom75)


    Don’t know if this might be a bug of wordpress or I do somthing wrong. I have created a standard theme. Works well so far. When it comes to adding a menu through a sidebar I get this warning.

    Fatal error: Uncaught TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in /[path]/wp-includes/class-walker-nav-menu.php:158

    Environment:
    WP 6.2
    PHP: 8.0

    In order to get rid the warning I have change the line 158 in the class-walker-nav-menu.php:158 as shown below.

    //	$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
    		$class_names = '';
    		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

    What I did to achive rendering a menu in the footer:
    I have registered a sidebar

    register_sidebar(
         array(
          'name' => esc_html__( 'Anywear Footer About', 'anywear'),
           'id' => 'anywear-footer-about',
          'class' => 'anywear-footer-about',
           'description' => 'AnyWear Dynamic Footer About Area',
          'before_widget' => '<section id="%1$s" class="anywear-footer-about-widget %2$s">',
           'after_widget' => '</section>',
           'before_title' => '<h2 class="anywear-footer-about-widget-title">',
           'after_title' => '</h2>'
         )
       );

    created the related sidebar.php

    if (!is_active_sidebar('anywear-footer-about')){
    
      return;
    
    } else {
    
      dynamic_sidebar('anywear-footer-about');
    
    }

    added the sidbar to the footer.php

    <?php get_sidebar('anywear-footer-about');?>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator threadi

    (@threadi)

    For me in the test with the information from you, I can not understand.

    Are you using the “nav_menu_css_class” filter at any point?

    Let’s output what

    apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth )

    generates (e.g. via var_dump()). I guess only a string comes out here, but it should be an array. If so, take a closer look at the values of the individual parameters.

    Thread Starter andom75

    (@andom75)

    Beg your pardon, yes your were right I had a filter in order to add custom classes. Have removed the filter and suddenly no warnings anymore.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Fatal error: Uncaught TypeError implode()’ is closed to new replies.