admin管理员组文章数量:1287776
I want to use jquery in my admin side programming but it seems there's no jquery loaded in the page at all and it load only at main website! Has my wordpress any problem which can't load jquery or I should do something extra to do it. However I put this code in function.php, but it not works:
if(is_admin()){
function load_admin_script(){
wp_enqueue_script('jquery_script', "/wp-includes/js/jquery/jquery.js");
}
add_action('admin_enqueue_scripts','load_admin_script');
}
I want to use jquery in my admin side programming but it seems there's no jquery loaded in the page at all and it load only at main website! Has my wordpress any problem which can't load jquery or I should do something extra to do it. However I put this code in function.php, but it not works:
if(is_admin()){
function load_admin_script(){
wp_enqueue_script('jquery_script', "/wp-includes/js/jquery/jquery.js");
}
add_action('admin_enqueue_scripts','load_admin_script');
}
Share
Improve this question
asked Feb 21, 2017 at 6:11
Siamak FerdosSiamak Ferdos
4831 gold badge6 silver badges8 bronze badges
2
|
2 Answers
Reset to default 2If you want to load Jquery, wordpress already provides a handler for it (its also the one in /wp-includes/js/jquery/jquery.js
):
function load_admin_script(){
wp_enqueue_script('jquery');
}
add_action('admin_enqueue_scripts','load_admin_script');
note that the jQuery in WordPress runs in noConflict mode.
You can use add_action hook to load your jquery in your admin area like below code.
<?php
add_action( 'admin_enqueue_scripts', 'load_jquery' );
function load_jquery() {
wp_enqueue_script('load_js',YOUR PATH.'/js/jquery.js');
}
?>
本文标签: Admin side jquery is not loaded
版权声明:本文标题:Admin side jquery is not loaded 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741263062a2367979.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp-admin
, so you shouldn't need extra CODE for that. Did you check your browser's developer console (right click -> inspect -> console
)? Perhaps there is a javascript error or some other theme / plugin is removing jQuery. – Fayaz Commented Feb 21, 2017 at 14:23