Child-Theme: Not all style is loaded from parent theme

My shop: https://shop.amir-rahbaran.com/

I’m having the issue, that not all styles are loaded into the child theme via functions.php (use version 1.0.5 from Github):

functions.php:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style'; // shapely	
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

    unset( $tabs['description'] );      	// Remove the description tab
    unset( $tabs['reviews'] ); 			// Remove the reviews tab
    unset( $tabs['additional_information'] );  	// Remove the additional information tab

    return $tabs;

}

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );

?>

Interesting: The whole style works with @import url(“…/shapely/style.css”);

If you’re interested to answer this on Stack Overflow as well, I also posted the question there:

Hi @amir,

I hope you are well today and thank you for your question.

To make it work you can try replacing the code of function my_theme_enqueue_styles with the following modified code.


      function my_theme_enqueue_styles() {
    
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array('shapely-bootstrap') );
        wp_dequeue_style('shapely-style');
        wp_enqueue_style( 'shapely-style',
            get_stylesheet_directory_uri() . '/style.css',
            array('parent-style')
        );
    }

Best Regards,
Movin

Hi @Movin,

Thanks for your fast reply. Unfortunately, this didn’t do the trick. Maybe more info from my site helps? This is my style.css from shapely-child:

/*
Theme Name: Shapely-Child
Template: shapely
Theme URI: https://colorlib.com/wp/themes/shapely
Author: colorlib - modified by Sandra J. / Amir R.
Author URI: https://colorlib.com/
Description: [...]
Version: 1.0.5
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: shapely
Tags: black, blue, brown, gray, green, orange, pink, purple, red, silver, tan, white, yellow, dark, light, left-sidebar, right-sidebar, fluid-layout, featured-images, post-formats, photoblogging, responsive-layout

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.

Shapely is based on Underscores http://underscores.me/, (C) 2012-2016 Automattic, Inc.
Underscores is distributed under the terms of the GNU GPL v2 or later.

Normalizing styles have been helped along thanks to the fine work of
Nicolas Gallagher and Jonathan Neal http://necolas.github.com/normalize.css/
@import url("../shapely-master/style.css");
*/

And my parent-style is called shapley-master and in the folder themes/shapely-master.

Thanks so much for your precious time.

Could you please share me your whole child theme directory so that i can troubleshoot it on my test site?

Also please tell me a bit more in detail what do you meant by “not all styles are loaded into the child theme via functions.php”?

Enclosed, you’ll find the zip file.

In style.css I commented out the @import line. If you uncomment the line, you’ll see that for example the button “Erfahren Sie mehr” on the front page is properly rendered (without round corners).

Thanks a bunch! :slight_smile:

Thank you for sharing the child theme.

To resolve the issue please make change in the function my_theme_enqueue_styles as i have described above and then change the following line in the style.css file of your child theme

Template: shapely

with the following line.

Template: shapely-master

Hello @Movin,

Sorry!!! I had already your functions.php updated in the online version (but not in the local functions.php).

However, I did the following change: Template: shapely-master

It’s still not working. Enclosed the latest version. Now even the @import in style.css is not. What could be the reason?

I have modified the above shared function my_theme_enqueue_styles so please try using that.

If it still doesn’t work for you then would you mind if i log in to your site and do some troubleshooting? If this is ok then could you please share me your site log in details privately by checking the option “Set as private reply” when replying to this topic?

OMG, it works now.

Thanks for your perseverance. :slight_smile:

Until launch, I’m sure there’ll be 3,4 more questions to come.

I can make you a log-in now or when the next question comes.

Best,
Amir

You are most welcome here :slight_smile: