How to redirect if is post edit or publish page?

I want to redirect if page is edit.php or post-new.php and i write this function. But it doesn’t work. It must work only ‘post’ post type.

add_filter(‘admin_menu’, ‘redirect’);
function redirect() {
require_once(ABSPATH . ‘wp-admin/includes/screen.php’);

$screen = get_current_screen();
if( $screen->post_type == ‘post’ && is_edit_page() ) {
wp_redirect(‘http://localhost/wordpress/’);
}

}

Read more here:: How to redirect if is post edit or publish page?

Leave a Reply

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