javascript - wp_head not working in plugin -
i've written simple plugin own use , i'm trying insert javascript head tag.
if use
add_action( 'init', 'add_to_head' );
then works, loads before jquery no good.
if use
add_action( 'wp_head', 'add_to_head' );
then nothing happens @ all! function i'm trying call.
function add_to_head() {?> <script>alert("test");</script><?php }
there's no errors in console unless use add_action 'init' says jquery not defined (obviously).
update
if use add_action( 'get_footer', 'add_to_head' ); works! i'm not sure if right hook use.
use wp_footer
hook, there nothing wrong use wp_footer
hook.
<?php function add_to_head() {?> <script>alert("test");</script><?php } add_action( 'wp_footer', 'add_to_head' ); ?>
Comments
Post a Comment