Hi
I want to add head script code into the website.
Is the best way via Child Theme?
What is the process and where is the Child Theme download?
Thanks
Marcus
Hey woogie07,
You can use a function like this in functions.php:
function woogie07_add_custom_code_head(){
?>
YOUR SCRIPT GOES HERE
<?php
}
add_action('wp_head', 'woogie07_add_custom_code_head');
A child theme can be downloaded here: https://kriesi.at/documentation/enfold/child-theme/
Best regards,
Rikard
Thanks,
Is that code you supplied based on adding the child theme first or can I do this without the child theme?
Do I need to change your references to woogie07 foir whatever name I want?
Thanks
Hi,
You could add the function container above to the parent theme but when you update it would be lost as the functions.php file is overwritten.
It would be better to first add a child theme and then add this to the child theme functions.php, please note that if you have more custom functions each one must have a different name, so your second function could be named like this:
function second_add_custom_code_head(){
?>
YOUR SCRIPT GOES HERE
<?php
}
add_action('wp_head', 'second_add_custom_code_head');
Best regards,
Mike
Thanks for this,
So function 1
function first_add_custom_code_head(){
?>
YOUR SCRIPT GOES HERE
<?php
}
add_action(‘wp_head’, ‘first_add_custom_code_head’);
function 2
function second_add_custom_code_head(){
?>
YOUR SCRIPT GOES HERE
<?php
}
add_action(‘wp_head’, ‘second_add_custom_code_head’);
and so on…?