Is there a way in which I can output some code in the header and choose it's location? some where like wp function add_admin_menu (where you can choose the placement).
1 Answer
Okay, here is a working example of what you (might) want to do.
Put the following in your functions.php
:
add_action('wp_head', 'my_jquery_code', 999999999);
function my_jquery_code() {
$jquery_code = <<<JQUERY
<script>
// jQuery code goes here...
</script>
JQUERY;
echo $jquery_code.PHP_EOL;
} // function my_jquery_code
@tf
in your comment. To your question,wp_head
is not the right hook. Trywp_print_scripts
instead. Anyway, what are you trying to do? Do you want to output some link to a CSS or JavaScript file? Please use thewp_enqueue_style
andwp_enqueue_script
functions for that. If it it still not what you want -> output buffer and filterwp_head
...?