0 votes
1 view
in Web Technology by (47.8k points)

How To Include CSS and jQuery in my WordPress plugin?

1 Answer

0 votes
by (107k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...