I have some script that is loading in the admin. I only need it to load on the new post and edit posts screens.

What is the best way to do this?

2 Answers
2

Check the page and enqueue your script accordingly:

global $pagenow;
if (! empty($pagenow) && ('post-new.php' === $pagenow || 'post.php' === $pagenow ))
    add_action('admin_enqueue_scripts', 'enqueue_my_scripts');

function enqueue_my_scripts() {
    wp_enqueue_script(...);
} // function enqueue_my_scripts

Leave a Reply

Your email address will not be published. Required fields are marked *