prevent loading related.css and widget.css
-
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://ww.wp.xz.cn/plugins/yet-another-related-posts-plugin/
-
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'); }great! thank you, it’s working
Thanks! Exactly what I needed.
By the way, we’re looking for YARPP beta testers. Please email us at [email protected] if you’re interested in providing invaluable feedback. Thanks!
I’m having sort of the same problem as OP.
4.2.2 is loading both
widget.cssandrelated.cssin the header. I want to dequeue (remove) both.widget.cssis easily removed thruwp_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 withget_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 toadd_action), but I just can’t seem to getrelated.cssremoved 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
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@longjorn β I tried that at first, copy/pasted verbatim.
That resulted in
related.cssbeing 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 (Withwp_dequeue_style('yarppRelatedCss');included in both functions being the first course of action).Alas, no dice. Thanks though!
Also, @jeffparker – please let me know if you need me to start another thread for this issue.
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?
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, 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!
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' );Thanks @ablears
Using the
wp_footeraction didn’t help, however β I then tried deregistering the file in the function that runs before, usingwp_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.phpnow: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' );I just had the same problem as @casper, I couldn’t remove the related.css from the footer even with the
wp_print_styleshook.Adding the action to the
wp_footersolved it finally.Thanks guys π
Same problem as @casper using quark template.
Only adding the action with wp_footer is preventing related.css to be loaded in the header… weird.@casper’s solution works for me on WP 4.0, the original one did not.
Yarpp, make it an option when using custom templates!!
The topic ‘prevent loading related.css and widget.css’ is closed to new replies.