Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (47.6k points)

How To Include CSS and jQuery in my WordPress plugin?

1 Answer

0 votes
by (106k points)

The best place to include CSS and jQuery in my WordPress plugin in your scripts and styles is within the wp_enqueue_scripts hook. Below is an example in which you can see these:-

add_action('wp_enqueue_scripts', 'callback_for_setting_up_scripts');

function callback_for_setting_up_scripts() { 

wp_register_style( 'namespace', '' );

wp_enqueue_style( 'namespace' );

wp_enqueue_script( 'namespace for script', '', array( 'jquery' ) ); }

What wp_enqueue_scripts action does is it set up the things for the "frontend". Whereas you can use the admin_enqueue_scripts action for the backend and the login_enqueue_scripts action for the login page.

Related questions

Browse Categories