Beep
Beep

Reputation: 2823

WordPress remove legacy CSS and include new CSS

Trying to remove old CSS and include new CSS, however when I inspect my code I still get the old CSS and not the new, have I written the code correctly?

My code

function se_remove_styles() {
    if ( is_page_template( 'template/page-main.php' ) ) {
        wp_dequeue_style( 'styles', get_template_directory_uri().'/assets/css/vendor.min.css',array(),'1.0.0');
        wp_enqueue_style('styles',get_template_directory_uri().'/assets/css/vendornew.min.css',array(),'1.0.0');
    }
}

add_action( 'wp_print_styles', 'se_remove_styles', 99 );

Upvotes: 1

Views: 177

Answers (1)

Henfs
Henfs

Reputation: 5411

Probably something related to cache.

One way to update CSS in Wordpress without having to refresh the cache through the browser is to update its version. As you see, the versions are 1.0.0 in both CSS you are calling. Change them to 1.0.1 and test it again. Like this:

function se_remove_styles() {
    if ( is_page_template( 'template/page-main.php' ) ) {
        wp_dequeue_style( 'styles', get_template_directory_uri().'/assets/css/vendor.min.css',array(),'1.0.1');
        wp_enqueue_style('styles',get_template_directory_uri().'/assets/css/vendornew.min.css',array(),'1.0.1');
    }
}

Upvotes: 1

Related Questions