trying to enqueue script in wordpress

You actually don’t need to worry about conflicting with the admin pages anymore. There is a “wp_enqueue_scripts” hook that makes sure the scripts aren’t called on admin pages.

From WP Codex:

<?php
function my_scripts_method() {
  wp_deregister_script( 'jquery' );
  wp_register_script( 'jquery',    'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
  wp_enqueue_script( 'jquery' );
}    

add_action('wp_enqueue_scripts', 'my_scripts_method');
?>

But if you need a custom jQuery core (or add-on) for the admin pages, you’ll need to use the “init” hook with the !admin conditional.

Leave a Comment