Hello readers, today I will guide you about How to remove parent(or default) JavaScript and css in wordpress child theme.
There are 2 ways to add css and js in your wordpress project.
- header.php
- functions.php
The below code defines that how to add css and js in your function.php file. You just copy mine code and put into your functions.php file and change css and js name with existing file name.
<?php
add_action( 'wp_print_scripts', 'parent_scripts' );
add_action( 'wp_print_styles', 'parent_styles' );
function parent_scripts() {
wp_enqueue_script( 'jquery-js', get_stylesheet_directory_uri() . '/js/jquery.js' );
}
function parent_styles() {
wp_enqueue_style( 'style-css', get_stylesheet_directory_uri() . '/css/style.css' );
}
?>
Remove parent css and js in child theme
If you don't need to default css and js in child theme, you just copy mine code below.
<?php
add_action( 'wp_print_scripts', 'child_overwrite_scripts', 100 );
add_action( 'wp_print_styles', 'child_overwrite_styles', 100 );
function child_overwrite_scripts() {
wp_deregister_script( jquery-js' );
}
function child_overwrite_styles() {
wp_deregister_style( 'style-css' );
}
?>
Hope it helps you. Thank-you Everyone!!
0 Comment(s)