How do I add my own scripts to the add_action(‘wp_enqueue_scripts’) function?

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!

Read more here:: How do I add my own scripts to the add_action(‘wp_enqueue_scripts’) function?

Leave a Reply

Your email address will not be published. Required fields are marked *