Guest, register

How To Insert JavaScript into WordPress Posts or Pages What we should know is that the CMS is basically differentiating between design and content. The administrator should be the one that inserts JavaScript so it should come as no surprise to notice that inserting JavaScript through the editor is something that is difficult to do. Thankfully, there are different ways in which you could achieve this. We will highlight those that are the most useful.

Label: CMS, JavaScript WordPress, WordPress Posts, WordPress Pages, Scripts n Styles, Script Tags Filtering

Free iPage Web Hosting for First Year NOW

If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with $1.89/month, included $500+ Free Extra Credits for the payment of 24 months ($45)?

Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you register the web hosting at iPage through our link, we're going to be happy for resending a full refund to you. That's awesome! You should try iPage web hosting for FREE now! And contact us for anything you need to know about iPage.
Try iPage for FREE First Year NOW

When you use the WordPress editor the text will be auto-formatted. This automatically restricts inserted script tags. People that want to insert JavaScript code into pages or posts will find this process to be quite frustrating. It also raises some WordPress security problems when it is done wrong.

Disabling Script Tags Filtering In WordPress

Only use this if you do trust your skills. Disabling script tags blocking is something that you can do. You will need to modify the wp-config.php file in order to enable the tags. You just have to define Custom_Tags as being TRUE. Then you want to make the necessary modifications for the functions.php page and you are done.

Remember that this is a method that should never be recommended unless you do know what you do. You are basically going to end up with the security feature being disabled for the entire site and you can add JavaScript at all user permission levels. If there are authors that do not know what to do it is better to simply not enable the option.

Using Plugins That Enable JavaScript Includes

image by

This is basically the simplest option that is available for you right now. You have access to so many useful plugins that will allow the management of JavaScript codes right within posts and pages. There are cases when you have to load JavaScript in the tag of a post or page or after content adjacent to the </body> tag.

In some situations you will want to load the script sitewide while in other cases you just want to focus on a post or a page. You can easily test various different plugins that offer the features you are looking for but the one that is by far the most comprehensive is Scripts n Styles. You would use this WordPress plugin in order to add the scripts you desire at a truly global level, for the entire site, or you can simply add at a post or page level.

By using the WordPress plugin recommended you can include the codes wherever you want to. Everything is simple to do but you still need to at least know exactly what the scripts will do. Since WordPress is made out of different scripts in itself, it is normal for some of the manually added scripts to simply not work well. If you want to use JavaScript codes that would modify some functions of the CMS system, it is better to be sure this is done by a professional. It is a lot more important than what you may think at the moment. You do not want to end up with the blogging platform to not work anymore.


Phong Thai Phong Thai is a Web Developer, Web Coder for 20 years with PHP, JavaScript, CSS. He is the creator of - provide thousands of free JavaScript code examples, web development tips and tricks, helpful blogging guides.

Follow him on twitter@js_bank or connect with him on facebook@jsbank if you want. His websites for your knowledge:,,
Save up to 630$ when buy new iPhone 15
Free Airdrops to Claim, Share Up to $150,000 per Project
Open tool hub for free to use by any one for every one with hundreds of tools,,,
Talk to ChatGPT by your mother language
Generate creative images automatically with AI
Render creative video automatically with AI

JavaScript by day

Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web