We are hooking admin_init
with the function load_my_script()
to tests the global $pagenow for a match with the admin page edit.php, and the global $typenow
to see if the post type is the one you want.
The rest are just details which you can read about here if you need to learn more:
1 2 3 4 5 6 7 8 9 10 |
<?php add_action('admin_init','load_my_script'); function load_my_script() { global $pagenow, $typenow; if ($pagenow=='edit.php' && $typenow=='my-custom-type') { $ss_url = get_bloginfo('stylesheet_directory'); wp_enqueue_script('jquery'); wp_enqueue_script('my-custom-script',"{$ss_url}/js/my-custom-script.js",array('jquery')); } } |
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.