How to Fully Include Parent Styles in Child Theme

  • Author
    Posts
  • #43354

    Hi There,

    I am trying to create a child theme from Parabola. I followed the instructions on the WordPress Codex page. They say not to use @import in your child’s stylesheet, rather they say to wp_enqueue_styles in your child’s functions.php. I am doing this, but when I preview the child theme, the styles aren’t loading correctly. The colors are there, but the fonts and the slider do not display correctly.

    I am not making any changes to the CSS, I want a child theme because I have some custom templates and PHP. Currently, I have to re-upload them every time the theme gets updated, so I am hoping to use a child theme, but since it seems that only half the stylesheet gets loaded, I’m not sure what to do.

    Thanks!

    Website: www.sarahsmathings.com

    #43380
    Zed
    Cryout Creations mastermind

    What code do you have in your child theme’s functions.php so far?


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
    #43394

    Thanks for replying. I currently have this:

    <?php
    function my_theme_enqueue_styles() {

    $parent_style = ‘parabola-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’ );
    ?>

    #43452

    Hi there, have you been able to identify what I may be doing wrong? I noticed that the parabola style.css has a line importing the fontfaces.css file. Since my child style is not registering the fonts, could it be that I need to enqueue this stylesheet as well?

    #43490
    Zed
    Cryout Creations mastermind

    You don’t need to enqueue the child theme’s style, as WordPress does that, and I don’t think the wp_enqueue_script hooks the right place to do this (that normally gets outputted in the footer).

    Try this code instead:

    // enqueue parent theme styling
    function child_parent_styling(){
    	wp_enqueue_style( 'parabola-parent', get_template_directory_uri() . '/style.css' ); // main style.css
    }
    add_action('wp_head','child_parent_styling', 4);

    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
    #43519

    That got it. Thanks so much!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How to Fully Include Parent Styles in Child Theme’ is closed to new replies.