Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

folks! I have taken it upon myself to adhere to WordPress conventions so I can have a clean, sexy child theme. However, I am unsure how to proceed on a certain issue.

I would like to override the CSS for some plugins in my WordPress website, and this wonderful post was a great step in the right direction. My only concern is that I would like to do everything I can to avoid overriding the header.php file in my parent theme in order the do this.

Is there another wonderful way to do this? Thanks for your help!

Update:

As was pointed out by another user's comment, this is in fact dependent on how the plugin implements its styles. This aside, assume that the plugins do provide a way for styles to be implemented in the style.css sheet of the child theme, or, in my case, a separate styles folder linked to that style.css sheet.

I also know I can use !important all over the place, but this is generally frowned upon.

share|improve this question
    
it depends entirely on how the plugins in question are adding their styles. –  Milo May 28 '13 at 17:19
    
I updated my post to accomodate your comment. Thanks! –  Jordan Thornquest May 28 '13 at 17:27
    
Close-voted as not constructive. Please edit your question to refer to specific Plugins, and include the specific CSS implementation code for those Plugins. –  Chip Bennett May 28 '13 at 20:00
    
I would love to, but unfortunately this is a pretty general question. My goal is to encapsulate all stylesheets that add custom edits to any plugin's styling in a single folder in my child theme. This keeps some really clean code, and is very efficient. I will add specific, code, though! –  Jordan Thornquest May 29 '13 at 16:58
    
I just found this Simple Custom CSS plugin It handles everything discussed for enqueuing dependent CSS. Simple to install and use. –  user41251 Sep 14 at 19:25

1 Answer 1

up vote 8 down vote accepted

If the plugins are correctly adding their styles via wp_enqueue_style, you simply need to dequeue them:

function wpa_dequeue_style() {
    wp_dequeue_style( 'plugin-style-handle' );
}
add_action( 'wp_enqueue_scripts', 'wpa_dequeue_style', 100 );

Whether or not this works depends on how and where the plugins are adding their styles, so there's no absolute answer without knowing specific methods the plugins in question use.

EDIT- another option that doesn't involve removing the styles entirely is to enqueue your own styles with the plugin styles as a dependency:

wp_enqueue_style(
    'my-styles',
    get_template_directory_uri() . '/mystyles.css',
    array('plugin-style-handle')
);
share|improve this answer
    
This is certainly a step in the right direction. However, my overrides are edits, so the trade-off of copy-pasting the entire stylesheet and editing it is a bit counter-productive. Like you said, it's also entirely dependent on how the css is added. –  Jordan Thornquest May 28 '13 at 17:39
2  
see edit above. –  Milo May 28 '13 at 17:44
    
I'll give that edit a shot. That looks like a great idea! –  Jordan Thornquest May 29 '13 at 16:58
    
Wow, I can't upvote enough. It worked! –  Jordan Thornquest May 29 '13 at 19:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.