CSS not making changes

I have a working child theme. Sometimes though, when I add CSS changes to the child theme, nothing happens. If I place the CSS code in Customize -> Additional CSS it works. Why? It drives me crazy.

Hello there,

Thank you for contacting us.

Your child theme may not load the style.css file properly. Please check in your child theme’s functions. Do you have lines of code that look like below?

    add_action( 'wp_enqueue_scripts', 'sydney_child_enqueue' );
    function sydney_child_enqueue() {

        $parent_style = 'parent-style';

        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')
        );

    }

Stay safe.
Have an excellent day :slight_smile:

Regards,
Kharis
aThemes Support

I have the following:

add_action( ‘wp_enqueue_scripts’, ‘sydney_child_enqueue’ );
function sydney_child_enqueue() {

wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

Hello there,

Thank you for updating me along with the code.

   get_template_directory_uri()

That line prints the URL parth to the main theme and it won’t load your child theme’s style.css file. Please replace it with:

   get_stylesheet_directory_uri()

And also replace parent-style to child-style.

I hope this replay helps.

Stay safe.
Have an excellent day :slight_smile:

Regards,
Kharis
aThemes Support

Thanks again for your help!

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis
aThemes Support

Hi, how do we change the functions if we have named our file/child theme something else other than sydney-child?

For example I have this:

<?php
add_action( 'wp_enqueue_scripts', 'sydney_child_enqueue_parent_styles');
function sydney_child_enqueue_parent_styles() {

  $parent_style = 'child-style';

  wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );

  wp_enqueue_style( 'sydney_child-style',
      get_stylesheet_directory_uri() . '/style.css',
      array( $parent_style ),
      wp_get_theme()->get('Version')
  );

}

But I would like to name my theme the name of my website and the stylesheet the name of my website. How would I make the changes to my functions and stylesheet to do that?

When I make these changes. the header gets destroyed.

Hello there,

When folder name of an active theme changed, it doesn’t affect the code as you shared. You don’t need to change anything on that code. But, the settings in customizer (under the Dashboard > Appearance menu > Cystomize) may be changed because the saved settings is tied to the folder name. Because WordPress recognizes it as different theme.

To pull the settings to the new theme’s folder name you can use the Customizer Export/Import plugin.

I hope this reply helps.

Stay safe.
Have an excellent day :slight_smile:

Regards,
Kharis
aThemes Support