按照如下所示,按照@gyo的建议和@Howdy\\u McGee在他的answer.
function admin_queue( $hook ) {
global $post;
if ( $hook == \'post-new.php\' || $hook == \'post.php\' ) {
if ( \'targeted-posttype\' === $post->post_type ) {
wp_enqueue_script(
\'custom-title-here\',
bloginfo( \'template_directory\' ) . \'/scripts/custom-script.js\',
\'jquery\',
\'\',
true
);
}
}
}
add_action( \'admin_enqueue_scripts\', \'admin_queue\' );