You can do it like this put in your functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 | function add_admin_scripts( $hook ) { global $post; if ( $hook == 'post-new.php' || $hook == 'post.php' ) { if ( 'recipes' === $post->post_type ) { wp_enqueue_script( 'myscript', get_stylesheet_directory_uri().'/js/myscript.js' ); } } } add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.