Site logo

Archived topic

Add jQuery code, js scripts, css links etc.

17 replies · Started by Leonardo on January 7, 2019

Viewing posts 1–15 of 18

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 recording

Have you tried the wp_footer hook I mentioned above instead of wp_head?

Yes, Leo
I tried wp_footer as well. Same problem. Do you have any other suggestions?
Greg

Are 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.

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
Greg

Can you link us to the page it's added to?

What's the script supposed to do?

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
Greg

Ah, so it creates an ad? How does it know where to show the ad if you add the script in wp_head or wp_footer?

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

Hi 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?

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?

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?

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.

This archived topic is closed to new replies.