$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - How do I add my own scripts to the add_action('wp_enqueue_scripts') function?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How do I add my own scripts to the add_action('wp_enqueue_scripts') function?

matteradmin9PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Yes

Post a comment

comment list (0)

  1. No comments so far