0

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!

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 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.