Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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' );
share|improve this answer
    
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 Jun 7 '12 at 4:52
    
@jw60660 Don't know, use fully qualified script. –  Eugene Manuilov Jun 7 '12 at 5:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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