This topic contains 17 replies, has 4 voices, and was last updated by Tom 5 months, 1 week ago.
January 7, 2019 at 3:14 pm #775703
How do I add jquery code, or any js code for that matter, on generate press? I found instructions only for wordpress.org, not for wordpress.com sites. (i.e. https://docs.generatepress.com/article/hooks-overview/ )
ThanksJanuary 7, 2019 at 5:07 pm #775772
Leo Customer Support
jQuery and js can usually go into the wp_footer hook.
It’s listed under Hooks Elements:
https://docs.generatepress.com/article/hooks-element-overview/January 9, 2019 at 3:48 pm #777748
I followed the video instructions for adding a code via wp-head hook. It did not work for me. See the screen recording. Please let me know where did I go wrong.
screen recordingJanuary 9, 2019 at 3:52 pm #777750
Leo Customer SupportJanuary 10, 2019 at 1:41 pm #778682
I tried wp_footer as well. Same problem. Do you have any other suggestions?
GregJanuary 10, 2019 at 4:34 pm #778765
Leo Customer SupportJanuary 10, 2019 at 7:30 pm #778830
You were partially right. That particular script might have a problem. I tested 3 other scripts on another wp site using another theme and the scripts worked perfectly well. The same scripts on the GP site failed.
Not sure what to do. I like the GP and already invested time and money in the GP Pro. I hope you might find some explanation and solution.
Here is one of the scripts you may want to try somewhere.
GregJanuary 11, 2019 at 10:30 am #779428
Tom Lead DeveloperJanuary 11, 2019 at 11:32 am #779470
Here is the link to a webpage where it is running.
Look under Hotels and Vacations sub-heading for Beaches resorts ad. That’s the script I sent you as an example.
GregJanuary 11, 2019 at 6:14 pm #779628
Tom Lead DeveloperJanuary 12, 2019 at 6:32 pm #780353
Tom, with all my due respect I fail to see the relevance to the fact that the script generates an ad or whether it is in the Head or footer of the page. Granted I could be missing something, but what is relevant to me is the fact that this and many other scripts work fine on the bucketlist.voyage WP site but none of the Jscripts I tried work on an another WP site that is using GP theme. I tried disabling all plugins, placing jscripts in the wp-head and wp-footer. nothing works. Could be some other factors besides the theme that I am not aware of. I am open to suggestions.
GregJanuary 12, 2019 at 8:38 pm #780391
Tom Lead Developer
It really depends on how the script works.
The theme itself doesn’t know how to prevent ads from displaying on a site. If the script is on the site and can run, it will work regardless of the theme.
However, adding a script into the header or footer of the page won’t add content (ads in this case) into the content area of your site, unless it knew exactly where to add it (which is likely doesn’t). There would typically have to be a script, or at least an HTML element, inside the content area of your website where the ad would eventually show up.
Are you sure the site that’s working doesn’t have another snippet of code within the content area where the ad displays? Is that content area just completely empty in the Dashboard?January 13, 2019 at 7:42 am #780725
you are up to something.
The working site has the script right in the content. And it fires up no problem.
This approach does not work on my GP site. What code should I put in the Content area in order to call the js from the wp_footer?January 13, 2019 at 9:15 am #780777
Tom Lead Developer
WordPress itself typically doesn’t allow
<script>elements directly in the content.
Does the other site have a plugin or function that overrides that limitation possibly?January 13, 2019 at 10:57 am #780834
Just to test your assumption I disabled all plugins and the script still worked.
Let’s not worry about the other theme. It helped to confirm that the script is functional. Now let’s concentrate on GP. You indicated that simply putting the script in the wp-head or wp-footer is not enough. Code must be placed in the content part of the page to call the script. You see the script. You know GeneratePress. Please suggest the code that in your opinion must be placed on the page.
Using JS is a common practice. Could you simply share what is the proper, specific, commonly accepted way to do it on a site that is using GeneratePress with the latest GP Pro plugin?
I am sure it would help other not super advanced users, like myself.
I followed the tutorial video that explained the use of elements. You explained that this is not sufficient and another code must be placed directly in the content ( within the <body> section I assume) part of the page. Please provide the code.
Thank you kindly.
You must be logged in to reply to this topic.