wp_head



EX1

function hook_css() {

    ?>

        <style>

            .wp_head_example {

                background-color : #f1f1f1;

            }

        </style>

    <?php

}

add_action('wp_head', 'hook_css');



EX2

function hook_javascript() {

    ?>

        <script>

            alert('Page is loading...');

        </script>

    <?php

}

add_action('wp_head', 'hook_javascript');



EX3

add_action('wp_head', 'add_css_head');

function add_css_head() {

   if ( is_user_logged_in() ) {

   ?>

      <style>

          .selector {display:block;}

      </style>

   <?php

   } else {

   ?>

      <style>

          .selector {display:none;}

      </style>

   <?php

   }

}





https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

Posted by cpu21