• Resolved manikum

    (@manikum)


    I am trying to put some script code in between <head> and </head> of the Virtue theme. One way is to use plugin ‘Header and Footer Script’. Could you tell me how to do it without installing plugin and doing changes in child theme of the plugin?

Viewing 6 replies - 1 through 6 (of 6 total)
  • hannah

    (@hannahritner)

    Hey,
    The premium theme has a built in place for you to add this, however the free theme does not. You would need to use a plugin or else a child theme. Sorry!

    Hannah

    Thread Starter manikum

    (@manikum)

    I am OK on working with a child theme as I wrote in my question details. Since as you wrote, it is possible to do it in free version using child theme, can you please tell me steps for it?

    hannah

    (@hannahritner)

    You should be able to paste it into your header.php file. Or you can use a simple plugin like this- https://wordpress.org/plugins/header-and-footer-scripts/

    Hannah

    Thread Starter manikum

    (@manikum)

    OK. That would help. Thanks 🙂

    So the template is in your templates folder templates/head.php

    But I would suggest you just add a function to pull the script into the header from your child theme functions.php file. like this:

    function custom_header_script() { 
     { ?>
      <!-- Script Starts -->
    <!-- End script -->
      <?php
      }
    }
    add_action('wp_head', 'custom_header_script', 20);

    Ben
    Kadence Themes

    Thread Starter manikum

    (@manikum)

    Thanks Ben! That was the exact procedure I was looking for. Could I add Boostrap CDN in the same way by writing it in between the script tag?

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding Script in Header without installing plugin’ is closed to new replies.