WordPress Snippets at WPcustoms

Hide VIEW button on post edit screen for custom post types

Remove the VIEW button in your post edit screen. Choose the custom post type where you want to modify the post_row_actions. The available fields have been added for reference.


/**
 * Snippet Name: Hide VIEW button on post edit screen for custom post types
 * Snippet URL: https://wpcustoms.net/snippets/hide-view-button-post-edit-screen-custom-post-types/
 */
  function wpc_remove_row_actions( $actions )

// reference:
// $actions['edit'] 
// $actions['inline hide-if-no-js'] 
// $actions['trash'] 
// $actions['view'] 

{
    if( get_post_type() === 'movies' ) // choose the post type where you want to hide the button
        unset( $actions['view'] ); // this hides the VIEW button on your edit post screen
    return $actions;
}
add_filter( 'post_row_actions', 'wpc_remove_row_actions', 10, 1 );