Site icon Catch Themes

Override Primary Menu via Child Theme

Greetings! Great theme. Once the client approves the look for their website, we will be purchasing the Pro version. In the meantime, I have been doing prep work. The client requests we keep the original top-navigation. So, I created a child theme, duplicated what was necessary, and replaced the Primary Menu code with a "require_once" statement. Problem is the child theme does not override the parent theme. I have tried the usual techniques (e.g., pluggable functions, function priority, and removing original hooks). None of them work. I tried different variations, like priority numbers, hook callouts (e.g., wp_loaded, init, clean_education_header, clean_education_after_header, etc.). Still no luck. Here's the parent and child theme code I am working with. Some help is greatly appreciated. Thanks in advance. Parent Theme:

if ( ! function_exists( 'clean_education_primary_menu' ) ) :
    function clean_education_primary_menu() {
        ?>
        <button id="menu-toggle-primary" class="menu-toggle"><?php esc_html_e( 'Menu', 'clean-education' ); ?></button>

        <div id="site-header-menu-primary" class="site-header-menu">
                <nav id="site-navigation-primary" class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'clean-education' ); ?>">
                <h3 class="screen-reader-text"><?php _e( 'Primary menu', 'clean-education' ); ?></h3>
                    <?php
                        if ( has_nav_menu( 'primary' ) ) {
                            $args = array(
                                'theme_location'    => 'primary',
                                'menu_class'        => 'menu primary-menu',
                                'container'         => false
                            );
                            wp_nav_menu( $args );
                        }
                        else {
                            wp_page_menu( array( 'menu_class'  => 'default-page-menu' ) );
                        }
                    ?>
                </nav><!-- .main-navigation -->
        </div><!-- .site-header-menu -->
    <?php
    }
endif;
add_action( 'clean_education_header', 'clean_education_primary_menu', 60 );
Child Theme:

    function clean_education_primary_menu() {
        ?>
        <button id="menu-toggle-primary" class="menu-toggle"><?php esc_html_e( 'Menu', 'clean-education' ); ?></button>

        <div id="site-header-menu-primary" class="site-header-menu">
                <nav id="site-navigation-primary" class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'clean-education' ); ?>">
                <h3 class="screen-reader-text"><?php _e( 'Primary menu', 'clean-education' ); ?></h3>
                    <?php require_once('topnav.php'); ?>
                </nav><!-- .main-navigation -->
        </div><!-- .site-header-menu -->
    <?php
    }
add_action( 'clean_education_header', 'clean_education_primary_menu', 65 );
function child_remove_parent_function() {
    remove_action( 'clean_education_header', 'clean_education_primary_menu', 60 );
}
add_action( 'wp_loaded', 'child_remove_parent_function' );
Exit mobile version