WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you add a script on the footer of the post editor ? I'm adding a meta box under the post editor and I need to include a javascript before the closing body tag (on the footer)

How do I achieve this ?

The script is not needed on the front-end just on that meta_box (just on the post editor page)

share|improve this question
up vote 4 down vote accepted

Hook into 'admin_footer-post-new.php' and 'admin_footer-post.php', check the global variable $post_type:

add_action( 'admin_footer-post-new.php', 'wpse_73692_script' );
add_action( 'admin_footer-post.php', 'wpse_73692_script' );

function wpse_73692_script()
    if ( 'post' !== $GLOBALS['post_type'] )

<script>alert( '<?php echo $GLOBALS['post_type'];?>' );</script>
share|improve this answer
Thanks man !!!. – user983248 Nov 23 '12 at 4:05
Where would you add this on a multi-site installation where you just want the script to fire in just one particular site? – Lynn Jan 11 '13 at 20:17
@Lynn In a plugin. Themes should handle the front-end only. – toscho Jan 11 '13 at 20:21
Ugh. For reasons i can't go into nor care to debate, I can't do this via a plugin. Or install a new one (new company policy right now). And out of interest in learning WP, I want to know if I could just put this into the functions.php file relevant to the one site I want my jQuery to fire on (when the Publish button is clicked) and have it hook into admin footer from there. – Lynn Jan 11 '13 at 20:27
@Lynn Then do it so. Try it, it should work. – toscho Jan 11 '13 at 20:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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