0

I am currently working on http://cryptoportugal.com/ and I'm still starting on Wordpress and I got stuck trying to add a javascript script (widget) to my website header. The script is the following - https://www.cryptocompare.com/dev/widget/wizard/?type=6&theme=0&fsym=BTC&tsyms=USD,EUR,CNY,GBP

Currently using MetroMagazine theme and I've tried installing a plugin such as 'Header and Footer' but I'm only able to add it to the footer.

I just can't find a way to edit the header. Help would be extremely appreciated!

Cheers!

2
  • Hi, can't you just simply add it to the header.php file in your template? Is there a restriction to do this?
    – Johansson
    Jan 22, 2017 at 0:26
  • @JackJohansson I've added it on the <head> section of header.php but still nothing shows up on the website. Jan 22, 2017 at 3:39

1 Answer 1

0

Don't edit theme files. Your changes will be overwritten when your theme updates.

Instead use a child theme and hook into the wp_head function. Add this to your child theme's functions.php file.

function add_js() {
?>
    <script>
        Your JavaScript goes here
    </script>
<?php
}
add_action('wp_head', 'add_js');

BTW, as you have a commercial theme, you can also get support from your theme vendor.

1
  • Thank you! Will look into this and update tomorrow with any trouble that might arise! Jan 22, 2017 at 3:40

Your Answer

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

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