- This topic has 11 replies, 3 voices, and was last updated 4 years, 4 months ago by
Jamal.
-
AuthorPosts
-
October 11, 2015 at 2:41 pm #143538
Andreas
Hi Guys,
how can I use JavaScript in a section without a plugin?
October 11, 2015 at 9:05 pm #143583Tom
Lead DeveloperLead DeveloperWhat are you trying to do within the sections using javascript?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 12, 2015 at 12:24 am #143609Andreas
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”.
October 12, 2015 at 10:20 am #143741Tom
Lead DeveloperLead DeveloperYou 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 π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 18, 2016 at 6:02 am #236388Jamal
Also for me javascript is not working in sections but i tried page header and it works !
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
October 18, 2016 at 9:13 am #236465Tom
Lead DeveloperLead DeveloperAre 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 18, 2016 at 12:31 pm #236551Jamal
This is what is not working in sections but is working in page header. I have enqueued the js file (?).
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
October 18, 2016 at 11:46 pm #236781Tom
Lead DeveloperLead DeveloperYea, 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.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 19, 2016 at 12:38 am #236804Jamal
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 π
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
October 19, 2016 at 10:21 am #237007Tom
Lead DeveloperLead DeveloperThe 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 19, 2016 at 11:35 am #237047Tom
Lead DeveloperLead DeveloperAh, 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 19, 2016 at 1:24 pm #237094Jamal
Thanks Tom, i will try that.
Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.
-
AuthorPosts
- You must be logged in to reply to this topic.