• I am creating a options page for a custom theme using add_menu_page() and some submenu pages using add_submenu_page(). Is it possible to add either a stylesheet or javascript to all my theme’s options pages with admin_print_scripts?

    So my code looks like this:

    $mypage = add_menu_page('Page title', 'Top-level menu title', 'administrator', 'my-top-level-handle', 'my_magic_function');
    add_submenu_page( 'my-top-level-handle', 'Page title', 'Sub-menu title', 'administrator', 'my-submenu-handle', 'my_magic_function');
    
    function mytheme_admin_head() {
    // this is where I would add javascript or css so it appears in the top of my theme's admin pages
    }
    
    add_action( "admin_print_scripts-$mypage", 'mytheme_admin_head' );

    Using the code I have above, the function mytheme_admin_head is only called on the main menu and not the submenu. Any solution?

  • The topic ‘admin_print_scripts hook for all submenu pages’ is closed to new replies.