0

I am creating a wordpress theme and my styles queue is not working.

This is the queue in functions.php

function style_script_enqueue(){
   wp_enqueue_style('main-styles', get_template_directory_uri() . '/css/main.css' );
   wp_enqueue_style('responsive-styles', get_template_directory_uri() . 
   '/css/responsive.css' );
   wp_enqueue_script('custom_script', get_template_directory_uri() . '/js/script.js', array(), '1.0.0', true);
}
add_action('wp_enqueue_scripts', 'style_script_enqueue');

I have also called wp_head(); , wp_footer(); , and checked the directory.

1
  • What is the error you are getting in console ? Commented Apr 23, 2022 at 19:34

2 Answers 2

0

Do you want to enqueue your CSS/JS in a child theme derived from another existing theme? Unless you build your own theme from scratch, child themes are the preferred practice to extend existing themes (update safe).

If you are in a child theme, there are two functions you might want to consider:

  • get_template_directory() or get_template_directory_uri() to refer to the parent theme path
  • get_stylesheet_directory or get_stylesheet_directory_uri() to refer to the child theme path

PS.: You might want to check if there are multiple functions registered for wp_enqueue_scripts, which try to enqueue CSS/JS with the identical name. If so, try to alter main-styles, responsive-styles, custom_script or the optional priority parameter for add_action as described in the function documentation.

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

Comments

0

Its work for me.

function add_css_js(){

// Load css 

wp_enqueue_style('style',get_template_directory_uri().'/assets/css/style.css',array(),'1.0.0','all'); 
    
//load JS

wp_enqueue_script('bootstrap',get_template_directory_uri().'/assets/js/bootstrap.min.js',array('jquery'),'1.0.0',true);

}add_action('wp_enqueue_scripts','add_css_js');

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.