0

According to the Pinterest website in order to add the Pinterest button to any page I have to add the following just below the closing body tag:

<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>

What's the best way to do this?

Should I follow the link, grab the script and use wp_enqueue_script? Or can I somehow include the script element another way?

Thanks.

1 Answer 1

2

Yes, you have to use wp_enqueue_script function. Pass $in_footer argument as true and your script will be added before closing body:

function my_scripts_method() {
    wp_enqueue_script( 'pinterest', '//assets.pinterest.com/js/pinit.js', array(), false, true);
}    
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
2
  • Actually the url gave me a 404 error, but that's exactly what was on the pinterest page. When I added the fully qualified url it gave me the script. Am I missing something?
    – jw60660
    Commented Jun 7, 2012 at 4:52
  • @jw60660 Don't know, use fully qualified script. Commented Jun 7, 2012 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.