How to add custom JS script to all WordPress Pages or Posts

In this short review, we will look at a very simple and easy-to-use solution for adding your code to the site.

For example, you need to add an analytics code, a chat script or chatbot, a Google Webmaster confirmation code, Yandex Metrika or something like that.

Of course, we can add code by editing theme files, but firstly it is inconvenient in further administration, and you also need to consider that when updating or changing the theme, your code will be deleted.

To avoid these problems, as well as for a convenient administration process, I recommend using the plugin

Let’s take a quick look at how it works.

The plugin is available in the WordPress Plugin Directory.
Here you can find the plugin description on the developer’s website.

After installation and activation, a new item appears in the settings (Dashboard – Setting – Heder and Footer)

Now we have the opportunity to add our custom code to all pages (in the <head> or <body> area, before or after the closing tags). It is also possible to add the code only for the desktop version, or only for the mobile version of the site.

Interface settings are simple and intuitive.

here we can add custom js script

Thus, you can easily add and administer all your custom code from one place.