Code for the Search Console

Hello!

I want to place a code in the head section, before the first body section of the theme .
How to do it??

Hi Pinelopi,

Thank you for reaching out to us. You can do this with wp_head action hook. Please see https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head and checkeout it’s examples in the guide. You’ll need to put the code in your child theme’s functions.php file. For example, you can try out adding the following code in your child theme’s functions.php file:

function hook_javascript() {
    ?>
        <script>
            alert('Page is loading...');
        </script>
    <?php
}
add_action('wp_head', 'hook_javascript');

This will be added in your head section of the site. You can then remove the test code and add your own one.

Hope this helps!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.