Javascript in Header
-
I’m trying to get a certain script to work.
If i put line 1 and 2 manually in a header.php, it works.
Now, (in order to avoid having to edit header.php every time) i’m trying to put it into a plugin.1)
<script src="https://extern.finnik.nl/kentekenbox/v1/kb.js" type="text/javascript"> </script>
I can see this appearing in my header when i look at the source of a page when i use this:
function my_finnik_js() { echo '<script type="text/javascript" src="https://extern.finnik.nl/kentekenbox/v1/kb.js"></script>'; } // Add hook for front-end <head></head> add_action('wp_head', 'my_finnik_js');
Now line 2)
2)<script type="text/javascript"> initFinnikKentekenbox('Het Automeisje', 'finnik-kentekenbox-container', 300, false); </script>
When i try to get this in the head also, with code below, it crashes my site.
function my_finnik2_js() { <?php wp_enqueue_script('custom', 'initFinnikKentekenbox('De leukste autosite van Nederland', 'finnik-kentekenbox-container', 300, false)'); ?> } // Add hook for front-end <head></head> add_action('wp_head', 'my_finnik2_js');
I’m an absolute beginner in this and i hope someone can tell me why it doesn’t work, or rather how it WILL work.
Thanks in advance, Marco
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Javascript in Header’ is closed to new replies.