Archived topic
Can't load javascript on single page with hook
13 replies · Started by Bonalair on January 25, 2021
Hello,
I have create a Hook but my javascript doesn't work on single page.
Could you please help me ?
Thnaks
Hi there,
what is the Javascript you want to add ?
Hello David,
I have tried the "hook methode" but with no success.
It's from Vibrant Media (https://www.vibrantmedia.com) and it was working good with my previous Wordpress Theme.
My javascript is : <script type="text/javascript" src="//k.intellitxt.com/inteItllitxt/front.asp?ipid=XXXXX"></script>
Thanks you for your help,
JC
Looking at that script it should be added to the wp_head hook and make sure the Display Rules are set to Entire Site ( or the pages you want it to execute ).
If you can do that and then link me to a page where the script should be, i can take a look to see if the hook is working.
It's done. I can see it with Ghostery for Google Chrome (Vibrant Ads) but the in-text advertising doesn't display. Here a link to the page : https://www.jcbtechno.com/
Thanks you
I just checked you site and i can see a banner advert above the content, and adverts in the sidebars on the home page.
Also see a pop up ad when clicking a post link.
And then in the content of a Single Post i can also see adverts being inserted.
Maybe try clearing your browser caches ?
Sorry David,
But it is not the problem, My browser cache is cleared.
I can not see my in-text ads (green color).
If you can not help me, no problem. I'm going to ask refund and reinstall Schema wordpress theme.
Thanks you,
JC
So i found this guide here:
https://www.vibrantmedia.com/de/wp-content/uploads/sites/2/2017/11/Vibrant-Implementation-Guide.pdf
So the scripts need to be fired after the content.
Try using the wp_footer hook to do that.
David,
I already done this. It doesn't work.
It's working with other wordpress them but not with GeneratePress, and i don't understand why.
Which hook do you have the script in now ? And can you move it to the footer hook so i can take another look?
Yes, wp-footer hook is already in place now.
Just to make sure, it's only not working on the home page?
If that's the case, can you try disabling all plugins except GP Premium to test?
Let me know :)
Hello Leo,
The problem is still here.
You can have a look on my website https://www.macplanete.com/
You will see it's working very well with other Wordpress theme like Schema (text link ads in green in single post).
Thanks you for your help.
The theme doesn't really matter when it comes to hooks like this - the hook isn't aware of the theme, it simply adds what you want it to add.
As a test, let's try some code that is completely separate from the theme - it would work with any theme you choose.
add_action( 'wp_footer', function() {
?>
Code in here will be added to the wp_footer hook regardless of the theme you choose.
<?php
} );
GeneratePress itself doesn't have the capability to prevent ads from being shown, so as long as the correct directions are being followed and the code is appearing in the source where it belongs, it should work.