You are on page 1of 7

How to Insert Javascript into a Wordpress Page /

Elementor Page

The problem is Wordpress delete any <script></script> tags (javascript code) in block content
automatically. There is only two ways to insert <script></script> automatically.

#1 - Insert as shortcode using Woody Snippets

1 - install Woody Snippets plugin


2 - click Add snippet

3 - Choose Universal Snippet


4 - Give the snippet a name (1)
(2) paste your javascript code in there

Don’t forget the <script></script> tags!

5 - Make sure you choose “Where there is a shortcode”

6 - Publish
7 - Copy this code. Paste this in the page & section where you want the code to show.

[wbcr_snippet id="5923"]

8 - in elementor I make shortcode block and paste it in.


#1B - Insert into a specific page based on PATH or RULE (no need for
shortcode)

Do steps 1-4

5 - Choose “Automatic Insertion” instead of shortcode

6 - Choose conditions on which page to insert the code

7 - There are many examples of what you can do.

● For entire site choose = Page Equals Entire Website


● For specific page = Current Page Equals checkout (the url path)
● Special woocommerce pages = Page Equals Checkout page
You can combine multiple conditions with OR and AND.
Save

8 - Don’t forget to clear cache / disable cache while testing.


Updating woodysnippets does not automatically clear / reset cache.
Everytime you change woody snippet you need to clear server cache.

9 - ALWAYS TEST! MAKE SURE YOU TEST AFTER you save. Make sure page loads

#2 - HTML Block in Elementor

1 - Type “html” and use this block called HTML. Look for the same icon.
(Not another block with similar name)

2 - Put <script> code in the block as you need.

You might also like