PHP, WordPress : Enqueue-ing scripts not working

  css, javascript, php, wordpress

Creating a custom WP theme from an HTML single page. In the header.php file I have the <?php wp_head();?>, in the footer.php file I have <?php wp_footer();?>. On my main page I have <?php get_header(); ?> and <?php get_footer(); ?> at the top and bottom respectively. When I "view source" the page looks like a single HTML file. In the browser, there’s no css styling or js. Therefore I think my problem is with my functions.php file (code below). I’ve been following this tutorial https://www.youtube.com/watch?v=FN5jhyspVXc&t=907s&ab_channel=MrDigital (enqueuing the scripts begins at 16:10). I’ve gone over it again, and again and again, but I still can’t seem to get my style and javascript scripts to load. I’ve also cleared both my wordpress and browser caches after saving any changes, and there’s no errors appearing in the javascript console. Any ideas of where or what the problem could be? Do I need to add anything to the beginning of my js or css pages? Should I combine the two functions?

<?php

//Load Style Sheet
function load_stylesheets(){
    
    wp_register_style('custom', get_template_directory_uri() . '/assets/style.css', array(), 1, 'all');
    wp_enqueue_style('custom');
    
}

add_action('wp_enqueue_scripts','load_stylesheets');

//Load Javascript
function load_js(){
    
    wp_register_script('javascript',get_template_directory_uri() . '/assets/portfolio.js', array(), 1, 1, 1);
    wp_enqueue_script('javascript');
}

add_action('wp_enqueue_scripts','load_js');

?>

Source: Ask Javascript Questions

LEAVE A COMMENT