Home » Hooks » post_row_actions

The "post_row_actions" hook is a WordPress hook that allows developers to add custom actions or links to the row actions section of the post listing in the WordPress admin area. This hook is particularly useful when you want to extend or modify the default row actions for posts.

By using the "post_row_actions" hook, you can add new actions or links that perform specific tasks related to posts. These actions can include editing, deleting, or performing custom actions on posts. The hook provides a way to enhance the functionality of the post listing screen and make it more personalized to suit your needs.

Here’s an example usage code that demonstrates how to add a custom action to the post row actions:

function add_custom_action_to_post_row_actions($actions, $post) {
    $actions['custom_action'] = '<a href="' . admin_url('admin.php?page=custom_action&id=' . $post->ID) . '">Custom Action</a>';
    return $actions;
add_filter('post_row_actions', 'add_custom_action_to_post_row_actions', 10, 2);

In the above code, we define a function named "add_custom_action_to_post_row_actions" that takes two parameters: $actions and $post. The $actions parameter represents the existing row actions, and the $post parameter represents the current post object.

Within the function, we add a new action called "custom_action" to the $actions array. This action includes a custom URL that links to a page where the custom action is performed. In this example, we’re using the admin_url() function to generate the URL for the custom action page and appending the post ID to it.

Finally, we use the "add_filter()" function to hook our custom function to the "post_row_actions" hook. This ensures that our custom action will be added to the post row actions in the admin area.

With this code in place, you’ll see a new "Custom Action" link in the row actions section of the post listing. Clicking on this link will take you to the custom action page, where you can perform your desired action for the specific post.

By leveraging the power of the "post_row_actions" hook, you can easily extend the functionality of the WordPress post listing and enhance the user experience for managing posts in the admin area.

Learn More on

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