admin管理员组文章数量:1130349
From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
Share Improve this question asked Nov 16, 2018 at 12:05 Toni Michel CaubetToni Michel Caubet 6163 gold badges11 silver badges33 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 2Please try to change handler common name.
From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
Share Improve this question asked Nov 16, 2018 at 12:05 Toni Michel CaubetToni Michel Caubet 6163 gold badges11 silver badges33 bronze badges 6-
Is it not working? Or not being loaded at all? There's no script tag in the document at all? Also,
wp_enqueue_scriptsdoesn't run in the admin, so! is_admin()is redundant. – Jacob Peattie Commented Nov 16, 2018 at 12:09 - 1 Try to change handler (common) name. – Pratik Patel Commented Nov 16, 2018 at 12:12
- @PratikPatel That worked, didn't know it was a reserved word. is it? – Toni Michel Caubet Commented Nov 16, 2018 at 12:19
- Yes may be its reserved word so thats why your script not load. – Pratik Patel Commented Nov 16, 2018 at 12:21
-
1
commonis used from WordPress itself. Though I usually advise for deleting questions, I think you should not in this case and let @PratikPatel write up an answer. Feels like this could be important for future visitors (with my comment I wanted to provide the link for where WP uses this) – kero Commented Nov 16, 2018 at 12:38
1 Answer
Reset to default 2Please try to change handler common name.
本文标签: Not all my scripts are enqueueing
版权声明:本文标题:Not all my scripts are enqueueing 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749174995a2327645.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


wp_enqueue_scriptsdoesn't run in the admin, so! is_admin()is redundant. – Jacob Peattie Commented Nov 16, 2018 at 12:09commonis used from WordPress itself. Though I usually advise for deleting questions, I think you should not in this case and let @PratikPatel write up an answer. Feels like this could be important for future visitors (with my comment I wanted to provide the link for where WP uses this) – kero Commented Nov 16, 2018 at 12:38