i want to hide few plugins style sheets to reduce load on our Index page and categories pages. Actually we want to display plugin style sheet only on Post not on other pages.
we have used following code in plugin, but it doesn’t work. please help how to use it.
if( is_single() || is_singular('post') ) wp_enqueue_style('savrix-style.css');
If you are modifying your own plugin I see no reason your code wouldn’t work. The
is_single()
condition is not needed, and will result in the stylesheet being loaded on custom post types and other singles that you don’t intend.However your
wp_enqueue_style
call is incomplete, so unless you have awp_register_style
call somewhere else defining the handle and URL of the stylesheet you need to change it to something along these lines:However, I get the impression that you are actually trying to remove a stylesheet included by a thirdparty plugin. It is generally a bad idea to modify a third-party plugin, as your modifications will be lost on the next update… it is very difficult to maintain that sort of modifications in the long run.
Instead make a new plugin and modify whatever you need from there.
What you want to achieve can be accomplished by:
Create a new folder in the
wp-content/plugins
folder, fx.my_load_reducer
.Inside that folder create a new file called
my_load_reducer.php
Paste this in the file:
Activate the plugin through the wordpress admin.
You can remove perticular plugin css on selected page.
below code is remove plugin css to other pages and display only on post pages:
where ‘plugin-css-handle’ is perticular plugin’s css handle which you want to remove.