WordPress comes with the ability to block the insertion of scripts into the content of your website directly. While some developers or website owners find this perturbing, it is not any development or design flaw. It is merely a security feature that protects your website from hackers.
- To add audio and video players that require script to run on the web page
- To create calculators and interactive pages that require integration of third party scripts within the website.
- Lead generation and subscription forms usually possess remotely loaded scripts.
Let’s picture it this way; you are developing plugin where you need to add jQuery and it works when you display the proper script tag in the header section. However, what if your another plugin requires the same jQuery? For developing another plugin with the same jQuery code, you will need to write the same code and execute it again. This leads to writing duplicate code and increasing the bandwidth of downloading the code twice.
Method 1: Using advanced custom fields
Advanced Custom Fields is one of the most popular WordPress plugins that enables website owners to add custom fields without having to touch even a single line of code.
In order to get started, you need to download and install the plugin on your website. Once installed, you will see a new menu option in your dashboard namely “Custom Fields”.
Click Custom Fields → add new. You will be redirected to a new page where you will be asked to fill your Field name. You can keep any name you want. You can choose the user type who would have the access to this custom field and would be allowed to use it.
There are various other options under the Options sections where you can select the section where you want to display the fields as well as the style type.
Now you would require adding Header and Footer scripts to display the script properly on the page. Make sure you set the formatting option as “Convert HTML into tags”.
Method 2: Using a Plugin