Javascript in Wordpress posts

2 replies
  • WEB DESIGN
  • |
I am fiddling with this for some time already but still dont have the perfect solution.

I have a page where i use a plugin which enables me to put "raw HTML" into a post or page. On this page are tables, forms, javascript etc.

The forms are using a bunch of external javascripts, like

http://www. somesite.com/scripts/somescript.js

I know we have a field below each post where we can put in javascript code, but the documentation for this is VERY cryptic.
I can put in direct code with functions in this field in wordpress, but can i also just put references to external scripts in there?

(Eg. except actual snippets of code i want to put in

<script> http://www. somesite.com/scripts/somescript.js </script>

But this does not seem to work! I also cannot get this to work when i put the script into the post (between my tags where i can post raw HTML).

And i also dont want to put this in the global site HEAD because that would be overkill. Any idea how can i do this, using external JS in wordpress?
#javascript #posts #wordpress
  • Profile picture of the author Istvan Horvath
    Using Javascript « WordPress Codex

    Did you try the method they give in the Codex?

    p.s. I've never seen any field below the post text area for inserting JS...
    Signature

    {{ DiscussionBoard.errors[5265218].message }}
  • Profile picture of the author ItWasLuck3
    wordpress.org/extend/plugins/allow-javascript-in-posts-and-pages/

    That link there is for a plugin I found. Looks like if you install that, you can just use the shortcode [js] [/js] to put javascript into any post or page. It's on the lower side with downloads (just a bit over 4000) but it might be worth a try if your trying to find the easy way to do it.
    {{ DiscussionBoard.errors[5265444].message }}

Trending Topics