3

I have a wordpress local installation and I am trying to load scripts and styles with wp_enqueue but none of these are working, the front-end is not capturing any of the files,

Here is the code:

<?php
function all_the_scripts() {
  wp_enqueue_style( 'style', get_stylesheet_uri() );
  wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css' );
  wp_enqueue_style( 'custom', get_template_directory_uri() . '/assets/css/custom.css' );
  wp_enqueue_script( 'bootstrap.bundle', get_template_directory_uri() . '/assets/js/bootstrap.bundle.js' , array ( 'jquery' ) );
  wp_enqueue_script( 'custom-scripts', get_template_directory_uri() . '/assets/js/custom-scripts.js', array ( 'jquery' ) ); 
}   
add_action( 'wp_enqueue_scripts', 'all_the_scripts' );
?>

I have double checked everything, all the files are in the correct locations and all required arguments are given, but still no result.

I tried wp_register_script but they say that it is optional and not needed

1
  • 1
    in which file you write this code ? function.php or somewhere else ? Commented Feb 17, 2018 at 17:01

1 Answer 1

2

Use get_stylesheet_directory_uri()

instead of

get_template_directory_uri()

The get_template_directory_uri() reference to the parent theme if you're developing Child Themes, and get_stylesheet_directory_uri() returns the URI of the current theme.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.