Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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, 3 months ago by gb.
    #1408838

    this 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.

    #1408839

    I 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.”

    #1408840

    I 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.

    #1408850

    Hi gb,

    Did you manage to get it working with the instructions from @guenni007?

    Best regards,
    Rikard

    #1408874

    Hi 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.

    #1408879

    i 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 tags

    #1408881

    Hi 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

    #1408891

    A 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.

    #1408896

    Hi,
    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,
    Mike

    #1408900

    Thanks 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

    #1408903

    Hi,
    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,
    Mike

    #1408904

    Thanks Mike, yes, you can close.

    #1408905

    Hi,
    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

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘How to add a script to my header?’ is closed to new replies.