Title: prevent loading related.css and widget.css
Last modified: August 21, 2016

---

# prevent loading related.css and widget.css

 *  Resolved [longjorn](https://wordpress.org/support/users/longjorn/)
 * (@longjorn)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/)
 * 4.2.2 is loading related.css in footer and widget.css in header.
    I am using 
   a custom template with my own styling which gets changed now by the related.css
   loading last..?? Using custom php under ‘Display options’ I want to be able to
   display related post in my own style. Can anyone tell me how to disable css loading
   or how to override styles which are loading at the end and are set to !important?
 * Switching back to 4.2.1 now ..
 * [https://wordpress.org/plugins/yet-another-related-posts-plugin/](https://wordpress.org/plugins/yet-another-related-posts-plugin/)

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [Abro](https://wordpress.org/support/users/abro/)
 * (@abro)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4901965)
 * Took me a minute, but this finally worked for me:
 *     ```
       //add this to your functions.php
   
       add_action('wp_print_styles','lm_dequeue_header_styles');
       function lm_dequeue_header_styles()
       {
         wp_dequeue_style('yarppWidgetCss');
       }
   
       add_action('get_footer','lm_dequeue_footer_styles');
       function lm_dequeue_footer_styles()
       {
         wp_dequeue_style('yarppRelatedCss');
       }
       ```
   
 *  Thread Starter [longjorn](https://wordpress.org/support/users/longjorn/)
 * (@longjorn)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902023)
 * great! thank you, it’s working
 *  [Sho-Down](https://wordpress.org/support/users/sho-down/)
 * (@sho-down)
 * [12 years ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902317)
 * Thanks! Exactly what I needed.
 *  Plugin Author [YARPP](https://wordpress.org/support/users/jeffparker/)
 * (@jeffparker)
 * [12 years ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902326)
 * By the way, we’re looking for YARPP beta testers. Please email us at [contact@yarpp.com](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/contact@yarpp.com?output_format=md)
   if you’re interested in providing invaluable feedback. Thanks!
 *  [cabgfx](https://wordpress.org/support/users/cabgfx/)
 * (@cabgfx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902336)
 * I’m having sort of the same problem as OP.
 * 4.2.2 is loading both `widget.css` and `related.css` in the header. I want to
   dequeue (remove) both.
 * `widget.css` is easily removed thru `wp_dequeue_style`:
 *     ```
       function my_theme_remove_assets_header() {
         wp_dequeue_style('yarppWidgetCss');
       }
       add_action( 'wp_print_styles', 'my_theme_remove_assets_header' );
       ```
   
 * However, if I try the same approach for `related.css`, that stylesheet instead
   gets loaded in the footer, with the scripts. If I then try to dequeue it with`
   get_footer`, eg.
 *     ```
       function my_theme_remove_assets_footer() {
         wp_dequeue_style('yarppRelatedCss');
       }
       add_action( 'get_footer', 'my_theme_remove_assets_footer' );
       ```
   
 * – it’s just loaded in the header instead.
 * I’ve tried dequeue’ing this stylesheet in both header & footer; tried using `
   wp_enqueue_scripts`; tried both dequeue’ing and deregistering, experimented with
   varying values for load priority ([third parameter to `add_action`](http://codex.wordpress.org/add_action#Parameters)),
   but I just can’t seem to get `related.css` removed completely.
 * Any help/info greatly appreciated — and thanks for an awesome plugin!
 * _WP 3.9.1, YARPP (Basic) 4.2.2, Apache 2.2.26, PHP 5.4.24_
 *  Thread Starter [longjorn](https://wordpress.org/support/users/longjorn/)
 * (@longjorn)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902337)
 * the solution Abro gave above is working fine on all sites I use.
    just copied
   and pasted to functions.php and there is no css loading anymore
 *  [cabgfx](https://wordpress.org/support/users/cabgfx/)
 * (@cabgfx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902338)
 * [@longjorn](https://wordpress.org/support/users/longjorn/) – I tried that at 
   first, copy/pasted verbatim.
 * That resulted in `related.css` being loaded in the header again (`<head>`, to
   be absolutely clear), which in turn sent me down the rabbit hole of trying every
   possible option for removing the stylesheet :S (With `wp_dequeue_style('yarppRelatedCss');`
   included in both functions being the first course of action).
 * Alas, no dice. Thanks though!
 *  [cabgfx](https://wordpress.org/support/users/cabgfx/)
 * (@cabgfx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902339)
 * Also, [@jeffparker](https://wordpress.org/support/users/jeffparker/) – please
   let me know if you need me to start another thread for this issue.
 *  Plugin Author [YARPP](https://wordpress.org/support/users/jeffparker/)
 * (@jeffparker)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902340)
 * Casper, I’m not sure what to tell you. The code works for me and for many other
   users. Perhaps you’re placing it in an odd location in the functions.php file?
 *  [cabgfx](https://wordpress.org/support/users/cabgfx/)
 * (@cabgfx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902341)
 * Thanks for replying, Jeff.
 * That’s unfortunately also the hunch I was having.
    I’ll go through everything,
   to see if there’s some other code inflicting this pain on me 🙂
 * FWIW, it’s a new theme I’m coding, so there’s only a couple plugins installed
   at the moment, and no weird/crazy customizations going on. I’m using the [Roots framework](http://roots.io/),
   if that’s relevant. Here’s the code in my functions.php:
 *     ```
       <?php
       /**
        * Custom functions
        */
   
       function my_theme_deregister_plugin_assets_header() {
         wp_dequeue_style('yarppWidgetCss');
       }
       add_action( 'wp_print_styles', 'my_theme_deregister_plugin_assets_header' );
   
       function my_theme_deregister_plugin_assets_footer() {
         wp_dequeue_style('yarppRelatedCss');
       }
       add_action( 'get_footer', 'my_theme_deregister_plugin_assets_footer' );
       ```
   
 * I’ll post back with whatever I find out.
 * Thanks again!
 *  [ablears](https://wordpress.org/support/users/ablears/)
 * (@ablears)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902347)
 * I’m using Roots too. Try using the wp_footer action instead. For example:
 *     ```
       function my_theme_deregister_plugin_assets_footer() {
         wp_dequeue_style('yarppRelatedCss');
       }
       add_action( 'wp_footer', 'my_theme_deregister_plugin_assets_footer' );
       ```
   
 *  [cabgfx](https://wordpress.org/support/users/cabgfx/)
 * (@cabgfx)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902348)
 * Thanks [@ablears](https://wordpress.org/support/users/ablears/)
 * Using the `wp_footer` action didn’t help, however – I then tried deregistering
   the file in the function that runs before, using `wp_print_styles`. That finally
   achieved my goal of removing the two plugin stylesheets. So thanks for putting
   me on the right track 🙂
 * For reference, here’s the code I have in my `functions.php` now:
 *     ```
       function my_theme_deregister_plugin_assets_header() {
         wp_dequeue_style('yarppWidgetCss');
         wp_deregister_style('yarppRelatedCss');
       }
       add_action( 'wp_print_styles', 'my_theme_deregister_plugin_assets_header' );
   
       function my_theme_deregister_plugin_assets_footer() {
         wp_dequeue_style('yarppRelatedCss');
       }
       add_action( 'wp_footer', 'my_theme_deregister_plugin_assets_footer' );
       ```
   
 *  [Zsolti](https://wordpress.org/support/users/sowad/)
 * (@sowad)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902349)
 * I just had the same problem as [@casper](https://wordpress.org/support/users/casper/),
   I couldn’t remove the _related.css_ from the footer even with the `wp_print_styles`
   hook.
 * Adding the action to the `wp_footer` solved it finally.
 * Thanks guys 🙂
 *  [bluantinoo](https://wordpress.org/support/users/bluantinoo/)
 * (@bluantinoo)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902353)
 * Same problem as [@casper](https://wordpress.org/support/users/casper/) using 
   quark template.
    Only adding the action with wp_footer is preventing related.
   css to be loaded in the header… weird.
 *  [aplusdesign](https://wordpress.org/support/users/aplusdesign/)
 * (@aplusdesign)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902354)
 * [@casper](https://wordpress.org/support/users/casper/)’s solution works for me
   on WP 4.0, the original one did not.
 * Yarpp, make it an option when using custom templates!!

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘prevent loading related.css and widget.css’ is closed to new replies.

 * ![](https://ps.w.org/yet-another-related-posts-plugin/assets/icon-256x256.png?
   rev=2549977)
 * [YARPP - Yet Another Related Posts Plugin](https://wordpress.org/plugins/yet-another-related-posts-plugin/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yet-another-related-posts-plugin/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/reviews/)

 * 15 replies
 * 9 participants
 * Last reply from: [aplusdesign](https://wordpress.org/support/users/aplusdesign/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/prevent-loading-relatedcss-and-widgetcss/#post-4902354)
 * Status: resolved