S
S
Satir012016-02-12 21:38:32
CMS
Satir01, 2016-02-12 21:38:32

How to change files in subdirectories of child wp theme?

Hello!
There is a file in the parent theme, for example:

theme/include/header.php
I 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.php
I make changes to it, but nothing happens. The parent rule changes, what am I doing wrong?
UPD
So. There is a theme/header.php file . In him
<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 -->

In the theme/structure/inc/header.php file , constructions like this
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 }
  }
}

Well, the theme/structure/inc/hooks.php file :
/**
 * 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

1 answer(s)
I
Igor Vorotnev, 2016-02-14
@HeadOnFire

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 question

Ask a Question

731 491 924 answers to any question