remove_action conditionally for Custom Post Type

Query variable only can be accessed after wp_query has been called. In you call, the get_post_type() function is actually returning an empty value. It should be working, if you change the hook to something which fires after wp_query is called.
So, You should use –

add_action('wp', 'kiwi_remove_post_author_box');

OR

add_action('template_redirect', 'kiwi_remove_post_author_box');

Also, hooks can removed with the same priority value the have been added on.
So final code it would be –

add_action('template_redirect', 'kiwi_remove_post_author_box');
function kiwi_remove_post_author_box()
{
    if( is_singular('wpseo_locations') )
        remove_action( 'woo_post_inside_after', 'woo_author_box', 10 );
}

Leave a Comment

tech