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?
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?
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