Archived topic
Use JavaScript in Sectoins
11 replies · Started by Anonymous on October 11, 2015
Hi Guys,
how can I use JavaScript in a section without a plugin?
What are you trying to do within the sections using javascript?
I'm using the facetwp Plugin and I want to generate a quick search form into a section. For insert PHP in a Wordpress page I'm using "Insert PHP".
You should just be able to put the javascript into the "Text" editor of the Section.
That being said, the WP editor has a habit of stripping some tags, so it might cause issues.
Worth a shot though :)
Also for me javascript is not working in sections but i tried page header and it works !
Are you entering JS straight into the editor? It seems WordPress strips javascript in the editor.
Instead, it should go in an external file or in the wp_footer hook.
This is what is not working in sections but is working in page header. I have enqueued the js file (?).
Yea, the editor will strip that. The Page Header actually should as well, I'll need to look at that.
That code should be added in the wp_footer hook.
Oh no when i thought i finally found the right design for my site :(
How can i output that script inside where the sections/page header is? Thanks
P.s Sorry if im talking gibberish, need to learn the right terminology :)
The location of javascript in the page doesn't matter. For speed purposes, it should be added to the footer, and it will still apply to your element in the sections/page header.
Ah, I understand, your JS displays data which you want in your section.
One thing you can do is add it to a shortcode which you then add to the section - WP won't strip the shortcode.
Thanks Tom, i will try that.