0

I have below snippet but it doesn't match what I want exactly.It avoids load any css file for my theme but also I want load stylepure.css. The stylepure css doesn't contain unused css so I want to load only it for my homepage. How can I except the css file? thanks

   function pm_remove_all_styles() {
        global $wp_styles;
        $wp_styles->queue = array();
        wp_register_script('hekimscripts_input', get_template_directory_uri() . '/js/stylespure.css', array(), '2.7.1'); // input css
         wp_enqueue_script('hekimscripts_input'); // Enqueue it!
    }
    add_action('wp_print_styles', 'pm_remove_all_styles', 100);

1 Answer 1

0

If this code works as excpected and you want to only limit it to front page you need to add a check for front page, like this

function pm_remove_all_styles() {
    if (!is_front_page()) return; // add this

    global $wp_styles;
    $wp_styles->queue = array();
    wp_register_script('hekimscripts_input', get_template_directory_uri() . '/js/stylespure.css', array(), '2.7.1'); // input css
     wp_enqueue_script('hekimscripts_input'); // Enqueue it!
}
add_action('wp_print_styles', 'pm_remove_all_styles', 100);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.