0
votes

I'm having trouble including css/js files with functions.php in wordpress and I don't know what im doing wrong looking at other forum posts.

Here is my functions.php

<?php

function home_script_enqueue() {

//css

wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/home.css', array(), '1.0.0', 'all');


//js

wp_enqueue_script( 'customjs', get_template_directory_uri() . '/js/home.js', array(), '1.0.0', true);


}

add_action('wp_enqueue_scripts()', 'home_script_enqueue');

In my header and footer file I have the wp_head(); and wp_footer(); function inside php tags

When I look at my Wordpress website and I inspect the code not only does nothing change but it doesn't read the the file at all and I'm not getting any errors.

1

1 Answers

0
votes

The problem is in your add_action() call.

You have:

add_action('wp_enqueue_scripts()', 'home_script_enqueue');

It should be:

add_action('wp_enqueue_scripts', 'home_script_enqueue');

Notice the lack of parenthesis in wp_enqueue_scripts?

For more details, please check the documentation: