admin管理员组文章数量:1130349
The challenge is, when you connect your template to display a specific category, to completely clear the contents of a function wp_head().
Perfectly done by the function remove_all_actions('wp_head').
But after that I need to connect my own styles and scripts to it (previously cleaned).
Why doesn't this design work?
1) Delete all:
remove_all_actions('wp_head');
2) Add my own style file via a standard hook 'wp_enqueue_scripts':
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
...has tried even so (, too, not works):
add_action('wp_head', function() {
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
});
Please tell me how to clean the function wp_head() re-start adding your files via 'wp_enqueue_scripts'?
Thank you!
The challenge is, when you connect your template to display a specific category, to completely clear the contents of a function wp_head().
Perfectly done by the function remove_all_actions('wp_head').
But after that I need to connect my own styles and scripts to it (previously cleaned).
Why doesn't this design work?
1) Delete all:
remove_all_actions('wp_head');
2) Add my own style file via a standard hook 'wp_enqueue_scripts':
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
...has tried even so (, too, not works):
add_action('wp_head', function() {
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
});
Please tell me how to clean the function wp_head() re-start adding your files via 'wp_enqueue_scripts'?
Thank you!
Share Improve this question edited Jan 3, 2019 at 13:43 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Jan 3, 2019 at 13:36 Alexander BattAlexander Batt 1 1- You removed all of the actions from wp_head, one of those actions prints scripts and styles. You probably want to dequeue all other scripts and styles rather than disable the entire enqueue system. – Milo Commented Jan 3, 2019 at 16:25
1 Answer
Reset to default 0You removed all of the actions from wp_head, one of those actions prints scripts and styles. You probably want to dequeue all other scripts and styles rather than disable the entire enqueue system.
Yes
The challenge is, when you connect your template to display a specific category, to completely clear the contents of a function wp_head().
Perfectly done by the function remove_all_actions('wp_head').
But after that I need to connect my own styles and scripts to it (previously cleaned).
Why doesn't this design work?
1) Delete all:
remove_all_actions('wp_head');
2) Add my own style file via a standard hook 'wp_enqueue_scripts':
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
...has tried even so (, too, not works):
add_action('wp_head', function() {
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
});
Please tell me how to clean the function wp_head() re-start adding your files via 'wp_enqueue_scripts'?
Thank you!
The challenge is, when you connect your template to display a specific category, to completely clear the contents of a function wp_head().
Perfectly done by the function remove_all_actions('wp_head').
But after that I need to connect my own styles and scripts to it (previously cleaned).
Why doesn't this design work?
1) Delete all:
remove_all_actions('wp_head');
2) Add my own style file via a standard hook 'wp_enqueue_scripts':
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
...has tried even so (, too, not works):
add_action('wp_head', function() {
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('project-main', get_project_directory_url() .'/animals/styles.css', false, '0.0.0', 'all');
});
});
Please tell me how to clean the function wp_head() re-start adding your files via 'wp_enqueue_scripts'?
Thank you!
Share Improve this question edited Jan 3, 2019 at 13:43 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Jan 3, 2019 at 13:36 Alexander BattAlexander Batt 1 1- You removed all of the actions from wp_head, one of those actions prints scripts and styles. You probably want to dequeue all other scripts and styles rather than disable the entire enqueue system. – Milo Commented Jan 3, 2019 at 16:25
1 Answer
Reset to default 0You removed all of the actions from wp_head, one of those actions prints scripts and styles. You probably want to dequeue all other scripts and styles rather than disable the entire enqueue system.
Yes
本文标签: javascriptHow do I add my own scripts to the addaction(39wpenqueuescripts39) function
版权声明:本文标题:javascript - How do I add my own scripts to the add_action('wp_enqueue_scripts') function? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749047893a2308154.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论