How to include css and js files in wordpress theme using functions.php Solution 2022

    By: Manu
    3 years ago

    How to include stylesheet in wordpress theme using functions.php, Well you can do this using below given code. You can include styles from desired path

        // including style.css in wordpress theme
        
        function includingStyleSheetForTheme(){
    
           // Loads theme's style.css from main directory 
    
             wp_enqueue_style('style', get_stylesheet_uri());
    
           // Loads other Theme Styles.
    
             wp_enqueue_style('bootstrap', get_theme_file_uri('assets/css/bootstrap.css'));
             wp_enqueue_style('main_icons', get_theme_file_uri('assets/css/maicons.css'));
             wp_enqueue_style('custom_theme', get_theme_file_uri('assets/css/theme.css'));
    
          // Include Javascript files.
    
             wp_enqueue_script('bootstrap', get_theme_file_uri('assets/js/bootstrap.bundle.min.js'));
             wp_enqueue_script('google_maps', get_theme_file_uri('assets/js/google-maps.js'));
             wp_enqueue_script('jquery', get_theme_file_uri('assets/js/jquery-3.5.1.min.js'));
             wp_enqueue_script('theme', get_theme_file_uri('assets/js/theme.js'));
        }
    
        add_action('wp_enqueue_scripts','includingStyleSheetForTheme');
    
    

    Now above code will include file "style.css" in wordpress theme