Created
December 28, 2018 18:16
-
-
Save ai2ik/2807103661e1cdd32e1f9d31b5f07485 to your computer and use it in GitHub Desktop.
To manually add script to the head of a WordPress site you can use the wp_head action by using one of the the following function examples in function.php If using the echo function you will need to use double quotes around scripts single quotes to keep from breaking the function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* add script to head with wrapping php | |
*/ | |
function addtohead_cf() { | |
?> | |
<script></script> | |
<?php | |
} | |
add_action('wp_head', 'addtohead_cf'); | |
/** | |
* add script to head using echo | |
*/ | |
function addtohead_cf() { | |
echo "<script></script>"; | |
} | |
add_action( 'wp_head', 'addtohead_cf' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment