-
AuthorPosts
-
May 28, 2023 at 6:12 am #1408836
Hi there,
I am using a third party service to integrate a text messenger into my WordPress site. The instructions say to paste the code snippet into the header. They suggest a plugin like Scripts & Styles or WP Code to add the custom code snippet to my theme.
Do I need that plugin or is there a way to add the code snippet just using Enfold?
Thanks,
GB
- This topic was modified 1 year, 6 months ago by gb.
May 28, 2023 at 6:40 am #1408838this might help –
that snippet comes to your child-theme functions.php:function your_custom_script(){ ?> <script> // replace that line here by your script code </script> <?php } add_action('wp_head', 'your_custom_script');
but How it is ultimately set also depends on whether it needs any requirements. E.g. the user script needs jQuery – then this must be loaded first before your user script is inserted.
May 28, 2023 at 6:45 am #1408839I think I got it working using the plugin WP Code Snippets.
Does Enfold need the plugin or can I just use your code? And where would I put the code that they request be placed:
“Add this code right before the </head> tag on your website page.”
May 28, 2023 at 6:52 am #1408840I just edited my reply when you inserted your return reply. The snippet above would then be sufficient – and the plugin would thus be superfluous.
But i do not know anything about your script – so it might be adjusted as said above.May 28, 2023 at 11:37 am #1408850May 28, 2023 at 4:41 pm #1408874Hi Rikard,
Actually not yet. I am not clear on the steps, could you clarify?
I imagine I would first disable the plugin WP Code, then paste the code snippet I have and the code Guenn provided but not sure where and in which order.
May 28, 2023 at 5:05 pm #1408879i do not know anything about your code provided by your third party service ( even if it is a javascript code – if it is only a style then we had to do it a different way )
but if it is a script code- then that code replaces the line:
// replace that line here by your script code
– so it is between the script tagsMay 28, 2023 at 5:10 pm #1408881Hi Guenn, thanks for the input. If you could explain the steps to do as I am not clear on that.
I have pasted the code in the private content area for review.
Thanks,
GB
May 28, 2023 at 8:06 pm #1408891A mod would have to give you guidance in this case – because as a participant, as you are, I do not see the private content area.
Or you post the code and replace only personalized information in this code (IDs or similar) – so it can’t be misused.
May 28, 2023 at 9:04 pm #1408896Hi,
Thanks for your patience if you are not using a child theme then using the plugin WP Code would be the correct solution. If you are using a child theme then you could add the code to the child theme functions.php file.
I assume that you don’t want your code shown publicly so I won’t paste it here in Guenni007‘s snippet:function your_custom_script(){ ?> <script> // replace that line here by your script code </script> <?php } add_action('wp_head', 'your_custom_script');
Please give this a try or include an admin login in the Private Content area so we can assist further.
Best regards,
MikeMay 28, 2023 at 10:51 pm #1408900Thanks for all the info guys,
I am not using a child theme (as far as I am aware. I never downloaded child theme attributes however I am building my site from an Enfold theme template but I believe that is not a child theme, correct?)
If that is the case then my current approach using the WP Code would be correct?
Thanks again for all the rapid support and community!
GB
May 28, 2023 at 11:09 pm #1408903Hi,
Yes using the WP Code plugin is the best approach, unless there is anything else we can help with on this issue, shall we close this then?Best regards,
MikeMay 28, 2023 at 11:10 pm #1408904Thanks Mike, yes, you can close.
May 28, 2023 at 11:29 pm #1408905Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘How to add a script to my header?’ is closed to new replies.