0
votes

I am trying to install a child theme on wordpress. for whatever reason I cannot install it because it says both themes identify as the child theme. I was having an issue when I created my child theme header so I went into the wordpress codex and just copied their style and replaced the relevant info. here is the style.css for the regular theme:

/*
 Theme Name:   consulting
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  consulting
 Author:       John Doe
 Author URI:   http://example.com
 Template:     consulting
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  consulting
*/

and for the child theme

/*
 Theme Name:   consulting-child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  consulting child theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     consulting-child
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  consulting-child
*/

i know they're case sensitive so I made sure everything is matching but still nothing. thanks for the help.

edit:

here's the functions.php code

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'consulting-style'; // This is 'consulting-style' for the consulting theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'consulting-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
1
the template of the child should be the name of parent themeTemani Afif
and remove template from parent theme ... there is a logic and if you read you code there is no relation between both, so you need to setup a relation and this relation is the templateTemani Afif
@TemaniAfif the consulting theme and child theme show up but clicking live preview on the child theme throws up an http 500 erroruser9340719
because you have to correct what i saidTemani Afif
@TemaniAfif I did correct what you said. I removed template from the parent theme and changed the name in the child themeuser9340719

1 Answers

0
votes

The Template line in the child theme corresponds to the directory name of the parent theme. If your parent theme is in a directory called "consulting", then this is what you want in the header of the child theme:

Template: consulting

Leave the template line out of the parent theme entirely.

Use this in your regular theme's style.css:

/*
 Theme Name:   consulting
 Theme URI:    http://example.com/consulting/
 Description:  consulting
 Author:       John Doe
 Author URI:   http://example.com
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  consulting
*/

And assuming your parent theme is in the "consulting" directory, use this in your child theme's style.css:

/*
 Theme Name:   consulting-child
 Theme URI:    http://example.com/consulting-child/
 Description:  consulting-child
 Author:       John Doe
 Author URI:   http://example.com
 Template:     consulting
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  consulting-child
*/