David Ansermot Web Developer / TYPO3 Integrator

2déc/090

Including JS and CSS in WP Header

Lot of people add Javascript and Css file by “echoing” them from theyre extension.
WordPress allow you to add correctly them to the page’s head by using two functions :

  1. // Add a new script file
  2. wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);
  3. wp_enqueue_script('jsfoo', '/wp-content/plugins/myplugin/JS/foo.js');
  4.  
  5. // Add a new stylesheet
  6. wp_enqueue_style($handle, $src, $deps, $ver, $media);
  7. wp_enqueue_style('main', '/wp-content/plugins/myplugin/main.css');

For more informations :
wp_enqueue_style();
wp_enqueue_script();

qrCode

Posts that maybe you want to read ::

Commentaires (0) Trackbacks (0)

Aucun commentaire pour l'instant


Leave a comment

(required)

Aucun trackbacks pour l'instant