Answer the question
In order to leave comments, you need to log in
How to change files in subdirectories of child wp theme?
Hello!
There is a file in the parent theme, for example:
theme/include/header.phpI create a directory in a child theme, copy the file I want to fix from the parent theme - it turns out
/theme-child/include/header.phpI make changes to it, but nothing happens. The parent rule changes, what am I doing wrong?
<header id="masthead" class="site-header" role="banner" <?php if ( get_header_image() != '' ) { echo 'style="background-image: url(' . esc_url( get_header_image() ) . ');"'; } ?>>
<div class="col-full">
<?php
/**
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
*/
do_action( 'storefront_header' ); ?>
</div>
</header><!-- #masthead -->
if ( ! function_exists( 'storefront_site_branding' ) ) {
/**
* Display Site Branding
* @since 1.0.0
* @return void
*/
function storefront_site_branding() {
if ( function_exists( 'jetpack_has_site_logo' ) && jetpack_has_site_logo() ) {
jetpack_the_site_logo();
} else { ?>
<div class="site-branding">
<div class="site-logo">
<img src="http://site.ru/images/logo-white_tran.png" class="" >
</div>
<div class="site-name">
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php if ( '' != get_bloginfo( 'description' ) ) { ?>
<p class="site-description"><?php echo bloginfo( 'description' ); ?></p>
</div>
<?php } ?>
</div>
<?php }
}
}
/**
* Header
* @see storefront_skip_links()
* @see storefront_secondary_navigation()
* @see storefront_site_branding()
* @see storefront_primary_navigation()
*/
add_action( 'storefront_header', 'storefront_skip_links', 0 );
add_action( 'storefront_header', 'storefront_site_branding', 20 );
add_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
add_action( 'storefront_header', 'storefront_primary_navigation', 50 );
Answer the question
In order to leave comments, you need to log in
Files from folders are usually not templates, but are template parts that are used in templates using the get_template_part( 'include/template-name' ) function, less often - include, include_once, require, require_once. You need to find this template itself in the root of the parent theme, and copy it too (it may be unchanged, but it must be in the child theme). Only then will you have the template_part from the child theme included.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question