0

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).

  • What do you mean by output some code and what location? Are you talking about the backend (admin) view or frontend view? – tfrommen Apr 14 '13 at 12:52
  • front end view and position is just after the load jquery? – user1888564 Apr 14 '13 at 12:55
  • 1
    You forgot the part "ask a separate question with much more details", as hinted in your previous Question... – brasofilo Apr 14 '13 at 13:00
  • had to break them up into two questions, don't know why the first one was closed :-(. seems its the consensus on here that if you know what you're looking for you ask a question so that someone can tell you what you already know) This ain't a place for people who are just starting out with Wordpress to further their career! – user1888564 Apr 14 '13 at 13:04
  • 1
    First, when writing a comment addressed to a certain user, use the ´@username` function, in my case just write @tf in your comment. To your question, wp_head is not the right hook. Try wp_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 the wp_enqueue_style and wp_enqueue_script functions for that. If it it still not what you want -> output buffer and filter wp_head...? – tfrommen Apr 14 '13 at 13:24
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.