[wp-hackers] identifying the current post type on admin screen.
frank at bueltge.de
Fri Jan 31 05:49:52 UTC 2014
Use the function get_current_screen to identifier the current page,
including post type.
You can use the plugin Debug Objects to see all data of get_current_screen
to easier understand the benefit.
Am 31.01.2014 05:15 schrieb "Andrew Nacin" <wp at andrewnacin.com>:
> On Thu, Jan 30, 2014 at 5:45 PM, Haluk Karamete <halukkaramete at gmail.com
> > on admin pages, how can I detect that the current admin is dealing with a
> > cpt?
> > dealing meas: he is about to "add new" or "edit" or "delete" a post that
> > belongs to that cpt.
> > something of this sort is what I'm looking for;
> > if (is_admin() and get_post_type( $post ) == 'that_cpt')
> > bingo...
> get_current_screen()->post_type. 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 for edit.php, post-new.php,
> and post.php (for all post types).
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers