Answer the question
In order to leave comments, you need to log in
How to connect styles and scripts to a WordPress plugin?
Good afternoon. I recently started making one plugin, and there was a problem that I can’t connect the styles and scripts that are in its directory to this plugin.
Tried something like this:
add_action('init', 'register_script');
function register_script() {
wp_register_script( 'custom_jquery', plugins_url('/js/custom-jquery.js', __FILE__), array('jquery'), '2.5.1' );
wp_register_style( 'new_style', plugins_url('/css/new-style.css', __FILE__), false, '1.0.0', 'all');
}
Answer the question
In order to leave comments, you need to log in
add_action('init', 'register_script');
function register_script() {
wp_register_script( 'custom_jquery', plugins_url('/js/custom-jquery.js', __FILE__), array('jquery'), '2.5.1' );
wp_register_style( 'new_style', plugins_url('/css/new-style.css', __FILE__), false, '1.0.0', 'all');
wp_enqueue_script('custom_jquery');
wp_enqueue_style('new_style' );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question