Archived topic
Adding Skimlinks code to the footer
5 replies · Started by April on February 22, 2021
I'm trying to get Skimlinks to work on my site. They provided javascript code to be placed "just before the /body tag". I created a hook in Elements which is assigned to wp_footer for the entire site.
When I use a Skimlinks test link, it says the installation failed. I've tried deleting the page cache but it's not working. Any ideas? Thanks.
Hi there,
Does Skimlinks have a documentation or any guide on how to install their product/s?
This seems like a question on how to install Skimlinks. If this is the case, it's best to ask the developer on how to install this on a WordPress site.
Note: I'm not exactly sure if this works but try this out - https://dougiehunt.com/beginners-guide-to-installing-skimlinks-on-wordpress/ (step 2 isn't exactly necessary if you follow this - https://docs.generatepress.com/article/adding-php/ - as its mainly for letting you add PHP snippets)
Skimlinks provides info how to install in Wordpress there is no "editor" option under Appearance in GP. That's why I'm coming to GP, not Skimlinks, because it appears to me to be a Wordpress difference due to the template (let me know if that's incorrect). See step 2 in the instructions provided: https://support.skimlinks.com/hc/en-us/articles/223836108
To clarify my questions:
1. If code needs to be placed just before the "/body" tag, did I do it correctly by using a hook assigned to wp_footer? Or should it be a different type of footer?
2. If the code that was provided to me (by Skimlinks) is javascript, should that work when it's pasted into a hook?
1.) It's the right hook but I think you have to change the priority if the script must go directly before the </body> closing tag. Try setting the priority of the Hook to 99 to do this.
say for example you have this:
add_action('wp_footer',function(){ ...code here... } );
You can add the priority by doing this:
add_action('wp_footer',function(){ ....code here... }, 99 );
2.) Yes it should as it on the Hook Element's code area. It's actually inserted as shown here: https://share.getcloudapp.com/OAug8Kw2 - It just happened to not be placed right before the closing body tag.
Awesome. I set the priority in the hook (it's in the option). Looking at the source code I can now see it right above /body. (I'm still getting an install error, but I'll hit them up now that I know it's in the right place.) Thanks!!
No problem. Hope it gets sorted. :D