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?
You must be logged in to post a comment.
Check the page and enqueue your script accordingly:
The global variable
$hook_suffix
is:post-new.php
for the new post andpost.php
for the regular post editorIn
wp-admin/admin-header.php
there are some special hooks:So you can use
admin_print_styles-$hook_suffix
, in your cases:To find the correct
$hook_suffix
for any admin page use something like this: