Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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', 'http://locationofcss.com/mycss.css' );

wp_enqueue_style( 'namespace' );

wp_enqueue_script( 'namespace for script', 'http://locationofscript.com/myscript.js', 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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...