Info in adding some java script code on theme

This topic has 6 replies, 3 voices, and was last updated 11 months, 3 weeks ago ago by Luca Rossi

  • Avatar: mirko
    mirko
    Participant
    December 28, 2023 at 14:45

    Hi I should add some java code in theme, to be exact just in the search bar, how do i do it/? which one is the line to edit?

    5 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    December 28, 2023 at 15:27

    Hello, Mirko,

    Thank you for reaching out to us with your query.

    You can use an additional plugin, like Insert Headers and Footers or add custom.js file inside child theme, here is an example – https://www.8theme.com/topic/styling-single-product-page-product-image-slider/#post-224893

    Kind Regards,
    8theme team

    Avatar: mirko
    mirko
    Participant
    December 28, 2023 at 18:16

    Not clear enought.

    Avatar: Justin
    Luca Rossi
    Support staff
    December 29, 2023 at 05:19

    Dear Mirko,

    We hope this message finds you well.

    Should you prefer not to utilize third-party plugins, we kindly suggest that you insert the code snippet provided below into the functions.php file within your child theme directory:

    
    add_action('wp_footer', 'n2t_wp_footer');
    function n2t_wp_footer(){
        ?>
        <script>
            /* your javascript code will go here */
        </script>
        <?php
    }
    

    Replace /* your javascript code will go here */ with your javascript codes.

    Should you require any further assistance, please do not hesitate to reach out.

    Best regards,
    The 8Theme Team

    Avatar: mirko
    mirko
    Participant
    December 29, 2023 at 07:58

    But there is talking about footer, the java code is for bar search.

    Avatar: Justin
    Luca Rossi
    Support staff
    December 29, 2023 at 10:24

    Dear Mirko,

    We would like to inform you that the aforementioned code will be strategically placed at the footer of the website. This is to ensure that all JavaScript libraries are fully loaded prior to the execution of your custom code.

    Could you kindly specify the code to which you are referring? We would greatly appreciate it if you could share it with us, allowing for a more thorough examination.

    Best regards,
    The 8Theme Team

  • Viewing 6 results - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.