Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

To solve this problem i've used this in my js file:

var location = String(window.location);

//only runs in post.php and post-new.php
if(location.search('post.php') != -1 || location.search('post-new.php') != -1 )
{

}

But it's does not seem like i solid solution. Are there any other way?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can use this in your functions.php :

function add_admin_scripts( $hook ) {

    if ( $hook == 'post-new.php' ) {

        wp_enqueue_script(  'myscript', get_bloginfo('template_directory').'/js/myscript.js' );

    }
}
add_action('admin_enqueue_scripts','add_admin_scripts',10,1);
share|improve this answer
    
What does, 10,1 in the add_action function means? –  Richard Jul 13 '11 at 11:47
1  
10 is the priority; 1 represents the number of variables passed to the callback. –  Chip Bennett Jul 13 '11 at 11:57
    
Note: you could also use the $pagenow global, using the same approach. –  Chip Bennett Jul 13 '11 at 12:00
add comment

Your Answer

 
discard

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.