Child Theme with custom inc files

Hello colorlib team,

I’m a user of your Dazzling theme for more than 6 months, and I have heavily customized it. I’ve built my own custom navwalker, for example. But now, I have a problem: I can’t use your updates anymore, and I can’t find a way to create a child theme with this customized component as it will throw an error because of redefinition of the class… Is it possible to add a if(!class_exists("wp_bootstrap_navwalker)) condition around the navwalker? If no, why? Is there another way?

Thank you for your time

Hi @gerkin,

I hope you are well today and thank you for your question.

There is another way to achieve this.

That class wp_bootstrap_navwalker is called in the following function and this function dazzling_header_menu is called in the header.php file of the theme so you can just overwrite the header.php file in your child theme and copy the following function & the class wp_bootstrap_navwalker in the functions.php file of your child theme then rename this functions and class and also there calls.

/**
 * header menu (should you choose to use one)
 */
function dazzling_header_menu() {
  // display the WordPress Custom Menu if available
  wp_nav_menu(array(
    'menu'              => 'primary',
    'theme_location'    => 'primary',
    'depth'             => 2,
    'container'         => 'div',
    'container_class'   => 'collapse navbar-collapse navbar-ex1-collapse',
    'menu_class'        => 'nav navbar-nav',
    'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
    'walker'            => new wp_bootstrap_navwalker()
  ));
} /* end header menu */

Best Regards,
Movin