Skip to content

Instantly share code, notes, and snippets.

@DomenicF
DomenicF / get_current_post_type.php
Last active Mar 12, 2020 — forked from bradvin/get_current_post_type.php
Get the current post_type context in the WordPress admin.
View get_current_post_type.php
<?php
/**
* gets the current post type in the WordPress Admin
*/
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
return $post->post_type;