How to Check if We Are on the Add New Post/Page/CPT Screen

A quick tip for setting conditions when we want to run a piece of code only on the the ‘Add New’ screen.

$screen = get_current_screen();

if ( ( 'post' === $screen->post_type ) && ( $current_screen->action == 'add' ) ) { 
// run our code

If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.

About Jean Galea

Jean Galea is a WordPress developer, entrepreneur and padel player. He is the founder of WP Mayor, the plugins WP RSS Aggregator and EDD Bookings, as well as the podcast. His personal blog can be found at

Related Articles

One Response

  1. teddy
    teddy January 1, 2014 at 19:28 | | Reply

    I think there’s typo, it should be `$screen` instead of `$current_screen`

Leave a Reply