The post_row_actions
filter allows you to modify the row action links in the non-hierarchical post types list table. The default row actions are ‘Edit’, ‘Quick Edit’, ‘Trash’, and ‘Preview’, available when you hover over a post row in the posts list table.
It is evaluated in the single_row()
method of WP_Posts_List_Table
in wp-admin/includes/class-wp-posts-list-table.php.
post_row_actions
only applies to list table views of non-hierarchical post types. Its sister filter, page_row_actions
applies to hierarchical post types, like pages.
The filter takes two arguments:
- array
$actions
The array of row actions, the key corresponding to the span class attribute of the element - object
$post
The post object
Example:
It seems to be more common for plugins or themes to modify post_row_actions
to add additional links, so what if we remove one instead? Let’s say you wanted to remove access to the use of Quick Edit if the post type is ‘post’.
Week 1 Recap: Filters 1-12 – Filters of the Day