I've posted a very similar question to this in the past but I'm still having trouble and I have new updates.
This is my website (http://cryptoportugal.com/) and I'm trying to insert a Javascript widget into my header which is currently not working. I'm using the 'Metro Magazine' theme.
I've tried using the plugin 'Header and Footer' but it'd only add it to the footer, for the header it just wouldn't work.
So I've went as far as opening the functions.php file for my theme and I've inserted the following code on the end:
function mytheme() { wp_register_script ('crypto', get_stylesheet_directory_uri() . '/js/crypto.js', true); wp_enqueue_script ('crypto'); } add_action( 'wp_enqueue_scripts', 'mytheme' );
And this is my script:
<script type="text/javascript"> baseUrl = "https://widgets.cryptocompare.com/"; var scripts = document.getElementsByTagName("script"); var embedder = scripts[ scripts.length - 1 ]; (function (){ var appName = encodeURIComponent(window.location.hostname); if(appName==""){appName="local";} var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; var theUrl = baseUrl+'serve/v1/coin/header? fsym=BTC&tsyms=USD,EUR,CNY,GBP'; s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + "app=" + appName; embedder.parentNode.appendChild(s); })(); </script>
Still nothing goes on, feels like there isn't even anything happening! :(
Help would be extremely appreciated,
thank you!
<script>
tags in a js file). Please, note that js questions it out of the scope of this site. If you have questions about js, you can try to post your questions in StackOverflow.