-
AuthorPosts
-
October 18, 2022 at 11:13 am #1369201
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
MarcusOctober 18, 2022 at 11:59 am #1369210Hey 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,
RikardOctober 18, 2022 at 12:09 pm #1369211Thanks,
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
October 18, 2022 at 12:50 pm #1369214Hi,
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,
MikeOctober 18, 2022 at 2:26 pm #1369223Thanks 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…?
October 18, 2022 at 3:08 pm #1369229 -
AuthorPosts
- You must be logged in to reply to this topic.
