heelo,
I want to use this great hook edit_form_after_title

it was announced on December 1, 2012:
http://make.wordpress.org/core/2012/12/01/more-hooks-on-the-edit-screen/

it curreclty hook for :
post-new, post, page-new, page.

how do I make it to work only in edit page/post (only post, page)

thanks all

3 s
3

Personally I’d use a different approach, because @Shazzad‘s solution seems too much global dependent, and @s_ha_dum‘s needs 2 hooks instead of one.

I’d use get_current_screen function to get a WP_Screen object, then I’d look at its property to run (or not) something after the title:

function do_something_after_title() {
    $scr = get_current_screen();
    if ( ( $scr->base !== 'post' && $scr->base !== 'page' ) || $scr->action === 'add' )
        return;
    echo '<h2>After title only for post or page edit screen</h2>';
}

add_action( 'edit_form_after_title', 'do_something_after_title' );

Leave a Reply

Your email address will not be published. Required fields are marked *