page_row_actions

Home » Hooks » page_row_actions

The "page_row_actions" hook is an important WordPress hook that allows developers to add custom actions to the row actions column on the pages list table in the WordPress admin area.

When this hook is triggered, it provides an opportunity to add or modify the actions available for each page in the row actions column. By default, the row actions column displays actions such as "Edit", "Quick Edit", "Trash", and "View". However, with the help of the "page_row_actions" hook, developers can add their own custom actions to this column, providing additional functionality and flexibility.

This hook is commonly used when developing WordPress plugins or themes that require custom actions to be performed on individual pages. For example, a plugin that adds a custom functionality to manage downloads may want to add an "Download Stats" action to the row actions column on the pages list table. By utilizing the "page_row_actions" hook, the plugin can easily add this action and handle the logic associated with it.

Here’s an example usage of the "page_row_actions" hook:

function add_custom_page_action($actions, $post) {
    // Add a custom action to the row actions column
    $actions['custom_action'] = '<a href="#">Custom Action</a>';
    return $actions;
}
add_filter('page_row_actions', 'add_custom_page_action', 10, 2);

In the above example, we define a callback function add_custom_page_action that takes two parameters: $actions (array) and $post (WP_Post object). Within the function, we add a custom action called "Custom Action" to the $actions array.

Finally, we hook our callback function to the "page_row_actions" filter using the add_filter() function, specifying the priority as 10 and the number of accepted arguments as 2.

With this code in place, the "Custom Action" link will be added to the row actions column for each page in the WordPress admin area.

Learn More on WordPress.org

WordPress snippets using the page_row_actions hook

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