2

Is it possible to remove the quick edit function for a custom post type?

I have 14 custom taxonomy with hundreds of terms in each and it takes too much time and resource to load all of them into the source-code of the page.

I tried to find a solution using google but most of them just hides the quick edit button, but the code is loaded in the footer by wordpress, so it doesn't really make any difference.

4

Check out the builk actions page in the codex. I believe the proper action to unset is inline. This will remove the "Edit" bulk action, which is actually quick edit.

<?php
    function remove_bulk_actions( $actions ){
        unset( $actions['inline'] );
        return $actions;
    }
    add_filter('bulk_actions-custom_post_type_slug','remove_bulk_actions');
?>

As for the Quick edit in each row, look into manage_{$post_type}_columns, as you may be able to replace the Title column with your own, and render it how you wish. There is currently no filters to remove Quick edit in the WP Posts List Table, so if the replacing of the column does not work, then you will need to create your own WP list table extension (Great tutorial).

  • Thanks! Alternatively, i can change the taxonomy to non-hierarchical when i'm on the post list page, because in that case its going to be an autocomplete input with ajax – passatgt Jan 4 '13 at 15:04
2

To clarify on Eric's post the add_filter code needs to have the screenid before the custom post type slug. The most common being bulk_actions-edit-custom_post_type_slug.

Also, unset( $actions['inline'] ) does not appear to be an option.

Both unset( $actions['edit'] ) and unset( $actions['trash'] ) were all I could find.

Finally, this code removes the Bulk Options Drop Menu Items, it does not remove the "Quick Edit" option which appears while hovering over a post.

function ssp_remove_member_bulk_actions( $actions ){
     unset( $actions['edit'] );
     return $actions;
}
add_filter('bulk_actions-edit-member','ssp_remove_member_bulk_actions');

THIS CODE Removes Quick Edit (thanks to jfacemyer)

function remove_quick_edit( $actions ) {    
     unset($actions['inline hide-if-no-js']);
     return $actions;
}
add_filter('post_row_actions','remove_quick_edit',10,1);

You can also turn off:

  1. edit = unset($actions['edit']);
  2. trash = unset($actions['trash']);
  3. view = unset($actions['view']);

To remove everything from the Quick Edit hover options:

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

Finally, you can only remove actions based on a Custom Post Type, or even user capabilities:

// Based on Post Type
if ($post->post_type=='myposttype') {
    unset($actions['edit']);
}
// Based on User Capability
if ( current_user_can('manage_options') ) {
   unset($actions['edit']);
}
0

The accepted answer modifies bulk edit dropdown, not post rows.

The filter you seek is in wp-admin/includes/class-wp-posts-list-table.php, line 1342 (WordPress 5.0.2):

/**
 * Filters the array of row action links on the Posts list table.
 *
 * The filter is evaluated only for non-hierarchical post types.
 *
 * @since 2.8.0
 *
 * @param array $actions An array of row action links. Defaults are
 *                         'Edit', 'Quick Edit', 'Restore', 'Trash',
 *                         'Delete Permanently', 'Preview', and 'View'.
 * @param WP_Post $post The post object.
 */
$actions = apply_filters( 'post_row_actions', $actions, $post );

This will work:

/**
 * This filter modifies "my_post_type" post rows,
 * such as "Edit", "Quick Edit" and "Trash".
 *
 * @param $actions
 * @param $post
 *
 * @return mixed
 */
add_filter('post_row_actions', function($action, $post) {
    if ($post->post_type == 'my_post_type') {
        // Remove "Quick Edit"
        unset($actions['inline hide-if-no-js']);
    }
    return $actions;
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.