• Resolved mgybran

    (@mgybran)


    Hi,

    I am using the free Astra theme.

    I have enqueued my parent and child style sheet in my child functions.php. I can therefore now see my child style sheet in the WordPress theme editor. This child style sheet contains all my child customized css.

    *** I want this child style sheet to be the base for all styles on the child and occasionally use the “additional css” editor (found in Appearance/Customize). How to do this? ***

    Situation at the moment is that the contents of the child style sheet are being ignored and the only way to apply changes is to use the Additional Css editor. This additional css editor is less easy to read (small interface on the left) and too much content in it (also less easy to read).

    Can anyone advise the way of achieving this?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @mgybran,

    There are several ways to add CSS to a WordPress site. Adding the CSS to the Additional CSS field of the Customizer and add the CSS to the child theme’s style.css file are two of them.

    If the custom CSS codes you added in the style.css file are not working, this could happen due to the browser cache of the child theme’s CSS file. Try updating the CHILD_THEME_ASTRA_CHILD_VERSION constant version to higher than 1.0.0 in the functions.php file of the Astra Child theme. Please refer to this screenshot.

    Clear the site cache and it should fix the issue.

    I hope it will help. Feel free to reach out to us if you have any further queries.

    Kind regards,
    Herman ??

    Thread Starter mgybran

    (@mgybran)

    Hi Herman,

    How do I clear the site cache? You are talking about at the hosting level, right?

    I read somewhere that it was only necessary to enqueue the parent style but I saw from your screenshot that you have enqueued the child stylesheet. I therefore tried to add that to my functions php

    ***
    function child_enqueue_styles() {

    wp_enqueue_style ( ‘astra-child-theme-css’, get_stylesheet_directory_uri () . ‘/style.css’, array(‘astra-theme-css’), CHILD_THEME_ASTRA_CHILD_VERSION, ‘all’ );
    }
    ***

    file but I get an error:

    ***
    Your PHP code changes were rolled back due to an error on line 12 of file wp-content/themes/astra-child/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘child_enqueue_styles’ (T_STRING), expecting ‘(‘
    ***
    I tried correcting it but errors continued, so I removed it.

    I tried your code:

    ***
    define ( ‘CHILD_THEME_ASTRA_CHILD_VERSION’, ‘1.1.0’,
    ***
    but get the same error.

    I include below what I have in my functions.php file:

    ***
    function example_enqueue_styles() {

    // enqueue parent styles
    wp_enqueue_style(‘parent-theme’, get_template_directory_uri() .’/style.css’);

    }
    add_action(‘wp_enqueue_scripts’, ‘example_enqueue_styles’);
    ***

    Thanks, Mitchell

    Thread Starter mgybran

    (@mgybran)

    Correction, my functions.php file content is below

    add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );

    function enqueue_parent_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );
    }

    Hi @mgybran,

    I was talking about the browser cache. But, you might also need to clear the site cache as well as the server cache, if your hosting provider has a built-in cache feature. You might need to get in touch with your hosting provider to know how to do that or refer to their knowledgebase.

    I am not sure why you had an issue with your child-theme’s functions.php. It used to work, right? What I would like you to do is just change the number, from. 1.0.0 to e.g. 1.0.1 and it will not give you any issue with the child-theme.

    If somehow you have an issue with your child-theme, you can always generate a new one from here.

    I hope it will help.

    Kind regards,
    Herman ??

    Thread Starter mgybran

    (@mgybran)

    Hi,That helped.

    I generated a new child theme and changed the version number. Now the stylesheet is being used and I can also use the customized css interface.

    Thanks for your help.
    Mitchell

    ??Perfect, @mgybran!

    Good to know that you have managed to make it work.

    Please mark the topic as resolved and do let us know if there’s anything else we can help you with.

    ??Have a nice day and stay safe!

    ??Kind regards,
    ?Herman ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to make css changes in child style sheet’ is closed to new replies.