How to Remove Edit, View, Trash and Quick Edit Links in WordPress Posts Admin

Home » Snippets » How to Remove Edit, View, Trash and Quick Edit Links in WordPress Posts Admin

Created with:



Creator: WPTurbo Team

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project

When managing your WordPress site’s posts, you may find that certain links clutter up the interface and take away from your workflow. In particular, the "Edit", "View", "Trash", and "Quick Edit" links can get in the way when you’re trying to make edits or manage your content efficiently. In this article, we’ll take a look at how you can easily remove these links from your posts admin screen to streamline your editing process.

					function wpturbo_remove_post_admin_links() {
    global $wp_post_types;
    $post_type = 'post';
    if (isset($wp_post_types[$post_type])) {
        $wp_post_types[$post_type]->show_in_quick_edit = false;
        $wp_post_types[$post_type]->show_in_menu = false;        
        $wp_post_types[$post_type]->publicly_queryable = false;
        $wp_post_types[$post_type]->exclude_from_search = true;
        remove_post_type_support($post_type, 'editor');
        remove_post_type_support($post_type, 'custom-fields');
add_action( 'init', 'wpturbo_remove_post_admin_links' );

This code snippet is designed to help WordPress developers remove the edit, view, trash and quick edit links within the posts admin section of WordPress.

The first step in customizing the post admin section is to create a function called wpturbo_remove_post_admin_links(). This function uses the $wp_post_types global variable to target the post post type that we want to modify.

The code snippet then sets several properties to false in order to hide the quick edit links and menu items related to posts. Specifically, the show_in_quick_edit and show_in_menu properties are both set to false, which effectively removes the quick edit and view links from the list of actions available for each post.

The snippet also sets the publicly_queryable and exclude_from_search properties to false, which helps to further limit the visibility of posts in searches and other areas of the site.

Finally, the snippet uses the remove_post_type_support function to remove the editor and custom fields from the post post type. This is one of the key steps in removing the edit, view, and trash links from the posts admin section.

The remove_post_type_support function is called twice in the code snippet, once for the editor and once for custom-fields. This effectively removes the related functions from the post edit screen, which helps to streamline the editing experience for users.

The last step is to hook the wpturbo_remove_post_admin_links() function to the init action, which ensures that it is called at the appropriate time during the WordPress page lifecycle.

By using this code snippet, developers can customize the posts admin section in WordPress to remove unwanted links and streamline the editing experience for users.

Register an account to save your snippets or go Pro to get more features.