Load in CSS and JS in functions.php

Load in js and css in functions.php

<?php
     
    if(!defined('ABSPATH')) { exit; }
     
    function foo_scripts() {
        wp_register_style('foo_css', get_template_directory_uri().'/style.css', array('foo_font_open_sans'));
        wp_register_style('foo_font_open_sans', '//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800');
     
        wp_register_script('foo_js_global', get_template_directory_uri().'/js/global.js', array('jquery'));
        wp_register_script('foo_js_actions', get_template_directory_uri().'/js/actions.js'));
     
        // will load foo_font_open_sans as well
        wp_enqueue_style('foo_css');
     
        wp_enqueue_script('foo_js_actions');
     
        // will load jquery
        wp_enqueue_script('foo_js_global');
    }
    add_action('wp_enqueue_scripts', 'foo_scripts');
?>

Add your comment