• Hello,
    I have been using Astra products and I am very happy with them. I have been running into an issue with using the child-theme and I am unable to find the solution. I have had this issue on multiple sites and I am needing some direction.

    I can successfully install and activate Astra’s child theme with FTP. My problem is that when I assign classes to sections or content on a page I am unable to see the changes when I code them in the style.css within the child theme (even with clearing the cache). I know that the child theme is connected successfully because I am able to see some changes when I use !important in my code. However, I know this is not best practice and my custom CSS almost never works.

    Here is an example of what is not working…
    .sectionHeader
    {
    color: red;
    }

    I am assuming that my issue is that other CSS scripts or inline CSS are taking precedence? Looking for any advice.

    • This topic was modified 3 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Possibly a precedence issue caused by either specificity or the order rules are encountered. Use your browser’s element inspector tool to see what rules are actually applied to a given element. Equivalent rules with less precedence will appear either lined through or grayed out. If the rule from your style.css is lined through, it’s a precedence issue. If the !important modifier works, this further reinforces the notion that precedence is the issue.

    To avoid the need to use !important, your rule either needs more specificity or it needs to occur later. If there are only a few problem rules, try placing them in the Additional CSS customizer section instead of in style.css.

    Thread Starter gwebgem

    (@gwebgem)

    Thank you for your response. It is looking like a precedence issue. I am hesitant to put them in the customizer for fear that theme updates may delete them. Is this a valid concern and is there a reason for the style.css in the child-theme to be called with greater precedence?

    Moderator bcworkz

    (@bcworkz)

    Customizer content is theme related and stored as a theme specific option value. However, it will reliably persist through theme updates. Updates replace theme files, not options data. A big reason there is a custom CSS section is precisely to protect custom CSS from theme updates.

    If you wanted to distribute your theme to others, the customizer wouldn’t be a good place for additional CSS, but for one particular site it’s fine. IMO it’s better than having to resort to the !important modifier. I really hate to use !important if I can at all help it.

    Thread Starter gwebgem

    (@gwebgem)

    Ok, this makes sense. Thank you so much. I guess now I am wondering how to apply wholesale changes easily. So, not just a few snippets of CSS, but rather a complete custom override of what a post or page design would default to. Do I create a new page.php or post.php file in the child-theme folder?

    Moderator bcworkz

    (@bcworkz)

    If you need to alter the HTML output, then a template file would need to be added or altered. A large amount of CSS ought to reside in its own file. The Additional CSS section wasn’t meant for many hundreds of lines of code.

    Is this child theme subject to periodic updates? Or is it a child you created yourself? It’s not good practice to add or alter files to any theme subject to periodic updates, child or not. Unfortunately, we cannot create our own grand-child themes to contain our custom work.

    Instead of a grand-child theme, we can create a plugin which contains our custom code. Loading a custom CSS file from a plugin is straight forward, but WP will not look in plugin folders for possible templates like it does for a child theme. The plugin has to force WP to use its templates for specific situations by using the “template_include” filter to lead to its template files.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Child Theme’ is closed to new replies.