What I am trying to achieve is to load a .js file on an edit.php page, however the code is not working specifically for this page. I've applied the same code type of code to other CPT pages, but for some reason this CPT page is not registering the script.
Here is the code I am using:
add_action( 'admin_menu', 'contacts_table_add_pages', 99 );
function contacts_table_add_pages(){
$menu = add_menu_page( 'Contacts', 'Contacts', 'publish_posts', 'edit.php?post_type=contact' );
$submenu = add_submenu_page('contacts', 'Add Contact', 'Add Contact', 'publish_posts', 'post-new.php?post_type=contact');
add_action( 'load-' . $menu, 'contacts_table_add_custom_css_js', 11 );
}
function contacts_table_add_custom_css_js() {
add_action( 'admin_enqueue_scripts', 'contacts_table_css_js', 11 );
}
function contacts_table_css_js() {
wp_enqueue_script( 'contacts', PLUGIN_URL . 'contacts/includes/contacts.js' );
}
The reason why I am creating a new CPT menu item is because it was once part of another plugin's submenu list - so I removed it from there and created its own menu item.
I've done the same for another plugin's CPT - and that one worked fine. It's just this CPT from another plugin that is not working.
Any clue on what may be going on?
Thanks, Roc.