• Hi everyone, I’m creating a child theme for the theme I’m currently using (Hueman)
    I want to import the parent theme stylesheet. I read there are two ways to do that:

    • Via the @import method
    • Via the wp_enqueue_style() function

    I heard the second method is better than the first (is it true?), so I created a file called functions.php in my child theme folder and added the following code:

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }

    The problem is that it’s not working. Can you tell me how to fix this? If not can I use the @method import or is it unpreferable?

    Thanks in advance

    • This topic was modified 9 years, 8 months ago by simsworldit.
    • This topic was modified 9 years, 8 months ago by simsworldit.
Viewing 1 replies (of 1 total)
  • You forget to add the child theme style.css.

    <?php
    function my_theme_enqueue_styles() {
    
        $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
    
        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' );
    ?>

    [Signature links removed by moderator per forum rules.]

    • This reply was modified 9 years, 8 months ago by James Huff.
Viewing 1 replies (of 1 total)

The topic ‘Importing parent theme stylesheet to child theme’ is closed to new replies.