I can’t enqueue my scripts – They literally aren’t being added to my site


Ok, I’ve literally copy-pasted different enqueueing code from about 5 different sources (Including wordpress), and not a single one works.

Here’s the code I’m using in functions.php:


function my_theme_scripts() {
        get_stylesheet_directory_uri() . '/js/main.js',
        array( 'jquery' ), '1.0.0', true

add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );


and it literally does nothing. No scripts added into my HTML. nothing.

This is my first time using wordpress, and nobody has explained the functions file to me completely right, but from my understanding, i don’t do anything like do I?

I’ve also put <?php wp_footer(); ?> right before </body> if that means anything.

I’ve solved the problem

Stupidly, I’d forgotten to add <?php wp_head(); ?> right before </head>, this screwed it all up. I also changed the ‘main’ identifier to something more unique, which didn’t change anything but might be a better practice anyway.

, , , Billy Ray Cyrus 1 year 2020-07-13T21:13:13-05:00 0 Answers 76 views 0

Leave an answer