How to Remove edit, view, trash and quick edit links within posts admin in wordpress

  • Post author:
  • Post category:Wordpress

To remove the “Edit,” “View,” “Trash,” and “Quick Edit” links within the posts admin in WordPress, you can use the following code snippet in your theme’s functions.php file or a custom plugin:

function remove_post_row_actions($actions) {
    if (get_post_type() === 'post') {
        unset($actions['edit']);
        unset($actions['view']);
        unset($actions['trash']);
        unset($actions['inline hide-if-no-js']);
    }
    return $actions;
}
add_filter('post_row_actions', 'remove_post_row_actions', 10, 1);

This code uses the post_row_actions filter to modify the actions displayed for posts in the admin area. It specifically targets the “Edit,” “View,” “Trash,” and “Quick Edit” actions for the ‘post’ post type and removes them from the array of actions.

Please note that modifying core WordPress functionality like this can affect the user experience, so make sure to consider the implications for your site’s administrators and content editors. Additionally, always make changes like these using a child theme or custom plugin to avoid losing modifications during theme updates.