i have stylesheet that loads on all of my pages in my wordpress theme. i want to disable it in landing.php . The file is in this address: http://example.com/wp-content/uploads/fusion-styles/fusion-22528.css i had tried these codes so far:
function themeslug_enqueue_style() {
if (is_page_template( 'landing.php' )) {
wp_enqueue_style( 'stylesheet', 'http://example.com/wp-
content/uploads/fusion-styles/fusion-22528.css', false );
}
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
and this one:
function se_remove_styles() {
if ( is_page_template( 'landing.php' ) ) {
wp_dequeue_style( 'http://example.com/wp-content/uploads/fusion-
styles/fusion-22528.css?timestamp=1510985246&ver=4.9' );
}
}
add_action( 'wp_print_styles', 'se_remove_styles', 99999 );action(
'wp_print_styles', 'se_remove_all_styles', 999999 );
but didnt worked. i had use this code:
function se_remove_all_styles() {
global $wp_styles;
if ( is_page_template( 'landing.php' ) ) {
$wp_styles->queue = array();
}
}
add_action( 'wp_print_styles', 'se_remove_all_styles', 99 );
but it will remove all of my styles.
any help will appreciated.
This code snippet removes queued CSS called "animate" from your WP frontend.
function se_remove_styles() {
wp_dequeue_style( 'animate' );
}
add_action( 'wp_enqueue_scripts', 'se_remove_styles',99999 );
So, how to get handle name of queued CSS? There are some ways to do it, here is one of them:
You will see the line like this:
< link rel="stylesheet" id="fusionblabla-css" href="http://example.com/wp-content/uploads/fusion-styles/fusion-22528.css" type="text/css" media="all" />
You see id='fusionblabla-css' there. Then "fusionblabla" is the handle name you are looking for. (not 'fusionblabla-css', but "'fusionblabla')
After it is done and you make sure that it is working you can add condition to that function
function se_remove_styles() {
if (SOME CONDITION HERE)
wp_dequeue_style( 'animate' );
}
add_action( 'wp_enqueue_scripts', 'se_remove_styles',99999 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With