简体   繁体   中英

Copy and replicate changes of file on from parent theme to child theme in Wordpress

I'm trying to reverse the styling of header logo title which based on my testing is located inside

/wp-content/themes/<theme-name>/inc/partials.php 

Since the file is under the Parent theme, I needed to replicate this file under the child theme directory

/wp-content/themes/<theme-name>-child/inc/partials.php

However, I can't seem to replicate it on my child theme.

For example, in the Parent theme directory, if I reverse the following code block:

<h2 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h2>

the changes are reflected on the homepage's header part, but if the same changes is applied on the child theme's version of the file, no changes are reflected.

I see that on the Parent theme, the

partials.php

is included in the

functions.php

as per the following code snippet:

/** Standard Includes */
$includes = array(

    '<other-files>.php',
    '<other-files>.php,

    'partials.php',
    '<other-files>.php',
);

foreach ( $includes as $file ) {
    require( get_template_directory() . '/inc/' . $file );
}

Copying this code inside the

functions.php

on the child theme directory doesn't make it work.

What should I do? What am I missing? TIA

get_template_directory function returns the parent theme path. Please check the referenced link.

In the case a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory.

You can change the get_template_directory() function to get_stylesheet_directory() function and copy all of those files into your child-theme but it's not recommended since your modification will lost after updating your theme.

I suggest you to contact to your theme author and asking them for a solution to override /inc/partials.php file into your child theme.

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