- This topic has 17 replies, 4 voices, and was last updated 4 years, 4 months ago by
Tom.
-
AuthorPosts
-
January 7, 2019 at 3:14 pm #775703
Leonardo
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/ )
Thanks
January 7, 2019 at 5:07 pm #775772Leo
StaffCustomer SupportHi there,
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 #777748Greg
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 #777750Leo
StaffCustomer SupportHave you tried the
wp_footer
hook I mentioned above instead ofwp_head
?January 10, 2019 at 1:41 pm #778682Greg
Yes, Leo
I tried wp_footer as well. Same problem. Do you have any other suggestions?
GregJanuary 10, 2019 at 4:34 pm #778765Leo
StaffCustomer SupportAre you sure the code itself is working? What are you adding?
The hook itself doesn’t do anything special to make the code work and not work – it simply runs it for you.
January 10, 2019 at 7:30 pm #778830Greg
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.
<script type=”text/javascript” language=”javascript” src=”http://www.anrdoezrs.net/placeholder-36345421?target=_top&mouseover=N”></script>Thank you.
Still hopeful
GregJanuary 11, 2019 at 10:30 am #779428Tom
Lead DeveloperLead DeveloperCan you link us to the page it’s added to?
What’s the script supposed to do?
January 11, 2019 at 11:32 am #779470Greg
Here is the link to a webpage where it is running.
http://www.bucketlist.voyage/trip-planner/
Look under Hotels and Vacations sub-heading for Beaches resorts ad. That’s the script I sent you as an example.
Thx
GregJanuary 11, 2019 at 6:14 pm #779628Tom
Lead DeveloperLead DeveloperAh, so it creates an ad? How does it know where to show the ad if you add the script in
wp_head
orwp_footer
?January 12, 2019 at 6:32 pm #780353Greg
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.
Greg
January 12, 2019 at 8:38 pm #780391Tom
Lead DeveloperLead DeveloperHi Greg,
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 #780725Greg
Tom,
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 #780777Tom
Lead DeveloperLead DeveloperWordPress 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 #780834Greg
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. -
AuthorPosts
- You must be logged in to reply to this topic.