How to remove CSS or Javascript file in the header using Wordpress functions.php

In Wordpress theme, sometimes there is an unwanted script file you want to remove or exclude, such as css files or Javascript files, or anything else that included within your current theme, this is how to remove CSS file in the header using Wordpress child theme's functions.php


How to remove files in the header using wp dequeue style/script and wp deregister style/script


Add the following code into child theme's functions.php

function dequeue_my_css_file() {
    wp_dequeue_style('name-of-the-css-file');
    wp_deregister_style('name-of-the-css-file');
}

add_action('wp_enqueue_scripts','dequeue_my_css_file',1000);

Give a higher number of priority to make sure your function executed after the parent theme's function. To prevent javascript files being included, you can also use the same method.

function dequeue_my_js_file() {
    wp_dequeue_script('name-of-the-js-file');
    wp_deregister_script('name-of-the-js-file');
}

add_action('wp_enqueue_scripts','dequeue_my_js_file',1001);

How to use remove_action function in Wordpress child theme

And for persistent parent function that you wanted to remove or you need to make sure the function in the parent theme doesn't run at all. you can remove the parent theme function from the hook it is attached to using the remove_action() or remove_filter() functions.

For example, you have this function in your parent theme:
function parent_theme_function() {
    // code.. code..
    // code.. code..
}
add_action( 'init', 'parent_theme_function' );

To remove parent theme function, you can write the following code in your child theme's functions.php
function remove_parent_function() {
    remove_action('init', 'parent_theme_function');
}
add_action('wp_loaded', 'remove_parent_function');

if the parent theme has priority number, you'll have to include it in the remove action method, for example:
function parent_theme_function() {
    // code.. code..
    // code.. code..
}
add_action('init', 'parent_theme_function', 101); // the priority number is 101

To remove parent theme function, you can write the following code in your child theme's functions.php
function remove_parent_function() {
    remove_action('init', 'parent_theme_function', 101); // include the same number which is 101
}
add_action('wp_loaded', 'remove_parent_function');

More..


Please activate Javascript then press (F5), to open the page properly
Click on the link.
How To Fix, Free APK, Android, iOS.
http://turefix.blogspot.com/