ThemeShaper Forums » Thematic

[closed]

Can't get child theme CSS to override parent CSS for the life of me

(11 posts)
  • Started 3 years ago by MTPrower
  • Latest reply from MTPrower
  • This topic is resolved
  1. MTPrower
    Member

    I have a brand-new installation of WordPress. Actually, this is like the 12th reinstall. This is the third theme I've tried and I've read all the highly-SEO'd articles on creating child themes. I can't get a child theme's CSS to override the parent's CSS for the life of me, in any of the themes. Been trying for a week.

    What I need is for a child theme to inherit all the CSS of a parent theme, but be able to have more CSS statements, which override, or add to, the parent theme CSS. I've been all over the web, trying to duplicate peoples' tutorials, and all I ever get is the parent theme's styling, no matter what theme is activated.

    Please help. My site URL is http://www.sonicreboot.com It's recently been reinstalled from scratch, and has got two plug-ins installed, neither of which affect the theme. I've done extensive plugin-compatibility testing and cache clearing.

    Posted 3 years ago #
  2. you must not be setting up your child theme properly. any style rule that is for the same element (and comes later as is the case of a child) or is more specific will take precedence. that's how CSS works.

    this is where i point people to get ground work on a child theme
    http://www.catswhocode.com/blog/wordpress-how-to-easily-create-a-thematic-child-theme

    also take a look in the thematic folder. there is a SAMPLE child theme already made for you. start with that.

    --- edited to add---
    i just took a look at your stylesheet. it looks correct. why don't you try to be more specific about what you are trying to change and we can probably help you better.

    Posted 3 years ago #
  3. MTPrower
    Member

    Holy crap I got it working. It apparently was already working, but it took me a close of the browser and a run of CCleaner. For some reason, a normal cache-clearing never did the trick.

    Of course, this is the first time it ever worked. It took a new theme (Thematic) and a fresh site install. But it works! After a whole week. Gah, I'm so relieved.

    Let's keep this topic open so I can easily address any remaining issues if they come up.

    Posted 3 years ago #
  4. MTPrower
    Member

    Alright, it updated again this morning. I make good CSS changes to the child theme, but they don't seem to show up for several hours at least. I clear my caches, restart my computer, run CCleaner, and start up my browser, but I have never gotten any changes until I do my morning boot-up. I asked my hosting if they cached my stuff, but they said they don't. They looked at my site for a while but say that it's not a problem on their side.

    When does my CSS update and why? I need to find a way to force it to update on cue. CTRL + F5 doesn't do the trick...

    Posted 3 years ago #
  5. hmm... unfortunately i don't know what to say. that isn't a thematic-related problem. you seem to have some very aggressive caching going on. anything in your htaccess? using a caching plugin?

    i did something once where i tacked on a timestamp in place of a version number to the main style.css. this meant that it essentially couldn't be cached b/c it will always have a new version number. not great long-term, but good while developing. this might help:

    http://www.ovalpixels.com/blog/2010/08/29/adding-automatic-css-timestamp-to-a-thematic-child-theme/

    Posted 3 years ago #
  6. Do you have caching plugin installed in WordPress? Disable it?

    Posted 3 years ago #
  7. MTPrower
    Member

    I have no caching installed. I have only two plugins installed for the time being: TheThe Sliding Panels and the WordPress Importer.

    Posted 3 years ago #
  8. found my version of the link i posted above

    // filter thematic_create_stylesheet to implement your own stylesheets
    function my_stylesheet($content) {
            $content = "\t";
            $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
            $content .= get_bloginfo('stylesheet_directory') . "/style.css?". date(U);
            $content .= "\" />";
            $content .= "\n\n";
    
            // $content will be handed back to thematic_create_stylesheet
        return $content;
    }
    // connect the filter to thematic_create_stylesheet
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');

    sidenote- i wouldn't try to do dev work on a live server, especially one that is doing such hard-core caching. i like working locally on XAMPP

    Posted 3 years ago #
  9. MTPrower
    Member

    I tried XAMPP and I can't seem to get a working installation of WordPress on it, even when I duplicate tutorials. Either I have really bad luck or I'm just stupid.

    In order to do that suggestion you're... suggesting... do I just add the code you posted into my parent theme's header.php?

    Posted 3 years ago #
  10. NO. drop it into your CHILD'S functions.php

    that is how child theming works. if you aren't clear on child theming then take a look at:
    www.catswhocode.com/blog/wordpress-how-to-easily-create-a-thematic-child-theme

    i'd try xampp again. i think i followed this one:
    http://webdesignerwall.com/tutorials/installing-wordpress-locally

    Posted 3 years ago #
  11. MTPrower
    Member

    I finally figured it out! I forgot I was using CloudFlare. I didn't know they were doing "aggressive caching" of my site...

    See, it's always something simple. Well, now I can get to making the coolest site theme I can possibly think of. Thanks everyone!

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.