Tagged: javascript, Pinterest, snippets
-
AuthorPosts
-
December 24, 2013 at 2:33 am #203422
I am trying to add a short piece of javascript to a number of pages on our website which uses the Enfold theme. This code will run a flash video of a person guiding visitors around our site..
I need to add the code to our home page and a number of other pages. The code works fine if I put it in the index.php page in the root directory, but doing this means we have the same video on every page. I don’t know where to place the code for it to work on the home page . I tried adding it to the Index template using the WordPress editor under the Appearance menu but it doesn’t seem to run there.
I am also having difficulty adding the code to any page in the form of plain text. I’ve tried adding the code to a text box but the code disappears after I save it, or the flash file runs immediately then hangs. So do you have any guidance you can give me as to the best place to insert this code and where do I place the code to work on the home page?
Thanks
Phil
PS here is the line I am inserting
<script type=”text/javascript”src=”http://xxxxxx.net/wp-content/uploads/2013/12/wothvideo.js”></script>
December 24, 2013 at 6:10 am #203461Hey phmorgan!
Please use this plugin: http://wordpress.org/plugins/insert-html-snippet/
This is will enable you to use javascript codes inside avia elements especially the Text Block element. Refer to this link for more info: http://docs.xyzscripts.com/wordpress-plugins/insert-html-snippet/
Regards,
IsmaelJanuary 13, 2014 at 12:22 pm #208903My site can be found at http://bit.ly/1fqPkFc.
I have used the snippet below on other themes and it works great. It adds a pop-up Pin It button to all images on hover, but I’m not sure where or how to add it to Enfold. I’d like to have it function on all pages.I could not add the Insert-html-snippet plugin mentioned above because it is out of date with the current WP version, so I tried one called Code Snippets which did nothing. I can’t tell where it is adding the code. I need it to go after the opening tag <body>
<script type=”text/javascript” src=”//assets.pinterest.com/js/pinit.js”
data-pin-hover=”true”
></script>January 14, 2014 at 12:53 pm #209423Hey!
Open up header.php and replace
<div id='wrap_all'>
with
<script type='text/javascript' src='//assets.pinterest.com/js/pinit.js' data-pin-hover='true'></script> <div id='wrap_all'>
Cheers!
PeterJanuary 14, 2014 at 4:09 pm #209496Okay, that works, but when I move to select the ‘Pin it’ it goes away before I can click on it.
Plus, I think this should rightfully go into a header.php file in my child theme. Can you point me in the direction of setting that up correctly? Do I just create a header.php child theme file and add this new snippet into it? It will overwrite the <div id=’wrap_all’> from the parent theme, right?
Thanks for your smart & speedy help!
-LynnJanuary 14, 2014 at 4:44 pm #209520Hey!
I can’t answer the first question (I don’t know how you can change or set up the pin) but yes, you can overwrite the parent theme file with the child theme. Just copy the header.php into your child theme folder and modify the file. Then save it and the child theme file should overwrite the parent theme file.
Best regards,
PeterJanuary 14, 2014 at 5:19 pm #209538Hey! Peter…
Thanks for helping with this. I think it could be of great use for all Enfold users.
Could this be the problem?
If you’re running our asynchronous script loader, add this line to set the data-pin-hover attribute:
p.setAttribute(‘data-pin-hover’, true);Where would I add this code?
Here is where Pinterest provides the dev info:
http://developers.pinterest.com/on_hover_pin_it_buttons/Thanks Lynn
January 15, 2014 at 5:45 pm #210128Hi!
Your best route would be to contact Pinterest support to assist in setting up or modifying the scripts they would like you to add to the page.
Regards,
DevinJanuary 16, 2014 at 12:34 am #210389I found it :)
Here is the link where I found the answer: http://business.pinterest.com/widget-builder/#do_pin_it_buttonAnd here is the code that worked:
<script type=”text/javascript” async data-pin-hover=”true” src=”//assets.pinterest.com/js/pinit.js”></script>
<div id=’wrap_all’> -
AuthorPosts
- The topic ‘Inserting simple Javascript code onto different pages’ is closed to new replies.