Due to the security systems that this CMS has, inserting a script directly can be a real headache.

The reason is that WordPress escapes some critical characters so that after inserting the script and reviewing the source code, we can find that it has only loaded the opening and closing tags.

But fortunately, the solution, beyond installing some plugin, is quite simple by editing functions.php. But if you don’t want to do it manually, you can refer any WordPress plugin to insert script code in the WordPress Header.

How to add a script in the WordPress header

We edit the functions.php of our active topic and we add the following:

function my_custom_js () {
    threw out ' ';
}
// This first hook (add_action) allows us to show the script in the private part of the web
add_action ('admin_head', 'my_custom_js');
// This other will make it visible in the public part
add_action ('wp_head', 'my_custom_js');

Where myjsfile.js It will be the name and path of the file that will contain the javascript functions that we want to insert.

And the bottom hooks enable where it will be displayed. We can add one or both, as appropriate.

Have you managed to solve your problem? Tell us!