Adding Script to Head Section of All Pages

Hey Themeco Team,

I’m trying to set up a Stripe payment form on one of my sites (https://stripe.com/docs/web/setup). Part of the instructions on the Stripe website say to add to the head of every page on my site. I attempted to add this to the functions.php file of my child theme but it breaks the site. Can you recommend how I can get this script added correctly?

Thank you!

Hey @bartenderonduty,

Please install and activate the child theme and login through FTP then edit the functions.php then add this code:


add_action('wp_head', 'add_header_code');
function add_header_code(){
?>
    <!-- Add the Stripe code here -->

    <?php
};

Please place the Stripe code in the <!-- Add the Stripe code here --> of the code above.

Hope this helps.

Thank you, this is perfect!

You’re welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.