On wp-hackers, Haluk Karamete asked:
on admin pages, how can I detect that the current admin is dealing with a cpt?
Andrew Nacin answered:
get_current_screen()->post_type
.[But] this will also specify a post type when it’s a taxonomy being edited. To filter that out, ensure that
get_current_screen()->base == 'post'
, which is [true] foredit.php
,post-new.php
, andpost.php
(for all post types).
Haluk didn’t elaborate on the cause of the question, but the answer is very good advice for those seeking to conditionally enqueue JS and styles only for specific post types.