I would like to add extra js file to a backend when editing or creating a custom post type.
I found pretty good answer to it but it has a flaw, it wont work when editing the custom post type, only on create and archive view.
Thank you :)
I would like to add extra js file to a backend when editing or creating a custom post type.
I found pretty good answer to it but it has a flaw, it wont work when editing the custom post type, only on create and archive view.
Thank you :)
Here you go:
add_action("admin_print_scripts","load_my_script");
function load_my_script() {
global $pagenow, $typenow;
if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php' && $typenow=='Custom_post_type_name') {
wp_enqueue_script('jquery');
}
}
just change Custom_post_type_name
to the actual name of your custom post type and enqueue your script.