[wp-hackers] identifying the current post type on admin screen.

Haluk Karamete halukkaramete at gmail.com
Fri Jan 31 05:58:30 UTC 2014


Thank you all.


On Thu, Jan 30, 2014 at 9:49 PM, Frank Bueltge <frank at bueltge.de> wrote:

> 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.
>
> Best Frank
> 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
> > >wrote:
> >
> > > 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
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list