简体   繁体   中英

Wordpress child theme fails to override parent theme for inc files

I'm fairly new to WP. I'm using the shop-isle theme that has its default search bar. I'm trying to override this search functionality with a custom search.

Theme header is loaded from directory shop-isle/inc/structure/header.php. I copied the entire directory to my child theme directory and made edits, but it does not work. I read on other post that inc files can't be overridden as they are not template files. I tried unhooking the function that loads the header but that removes the header all together!

The main header.php calls shop-isle/inc/structure/header.php. using

    <?php do_action( 'shop_isle_header' ); ?>

The hooks.php located in shop-isle/inc/structure/hooks.php has the callback function registered using

add_action( 'shop_isle_header', 'shop_isle_primary_navigation',   50 );

I've copied all these files over to my child theme so i can edit the shop_isle_primary_navigation callback function but it does not override the parent files.

You should put your modified shop_isle_primary_navigation function in child theme functions.php.

The child theme functions get loaded before functions from the parent theme. Since these are enclosed in if ( ! function_exists ( 'some_function' ) ) { ... } they won't be loaded.

No need to copy everything to child theme directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM