This is in reference to another answer here on wordpress.stackexchange. The answerer used the filename as the hook to enqueue scripts and styles to certain pages.

add_action( 'admin_print_scripts-post-new.php', 'portfolio_admin_script', 11 );
add_action( 'admin_print_scripts-post.php', 'portfolio_admin_script', 11 );

The short answer is 'yes'.

Taken from this article the suffix of those 'screen specific hooks' is given by:

  • For custom admin pages added via add_menu_page() - including settings pages - (and related functions) it is the screen ID (the value returned by add_menu_page())
  • For the admin page listing posts of any post type, it is edit.php
  • On the ‘add new’ page of any post type, it is post-new.php
  • On the edit page of any post type, it is post.php
  • For taxonomy pages it is edit-tags.php

You may find this plug-in useful, developed by @Kaiser, based on the article linked to above.

  • 1
    You know how to get upvotes ;) - Note for later readers: The plugin was based on a concept developed by @StephenHarris. – kaiser Nov 26 '12 at 2:41
  • 1
    If you look at the source of any admin page there is a a little bit of Javascript near the top that reveals those hook names, or enough of them that you can work out the rest, and a few other things. – s_ha_dum Nov 26 '12 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.