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

Morgan Estes morgan.estes at gmail.com
Fri Jan 31 04:07:50 UTC 2014


There are a couple of ways to get the post type of the page being edited.
Here's one works for me:

add_filter( 'admin_head', 'get_cpt_page' );

function get_cpt_page() {
if ( 'that_cpt' == get_post_type() ) {
          // do cool stuff here
        }
}

Morgan W. Estes
about.me/morganestes


On Thu, Jan 30, 2014 at 4: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...
>
> which obviously would not work.
> _______________________________________________
> 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