The post_unstuck WordPress PHP action fires once a post has been removed from the sticky list.
Usage
add_action('post_unstuck', 'your_custom_function', 10, 1); function your_custom_function($post_id) { // your custom code here }
Parameters
$post_id
(int): ID of the post that was unstuck.
More information
See WordPress Developer Resources: post_unstuck
Examples
Log unstuck post
Log the ID of the post that has been unstuck.
add_action('post_unstuck', 'log_unstuck_post', 10, 1); function log_unstuck_post($post_id) { error_log("Post with ID {$post_id} has been unstuck."); }
Notify admin about unstuck post
Send an email to the admin when a post is unstuck.
add_action('post_unstuck', 'notify_admin_unstuck_post', 10, 1); function notify_admin_unstuck_post($post_id) { $admin_email = get_option('admin_email'); $subject = "Post Unstuck"; $message = "A post with ID {$post_id} has been unstuck."; wp_mail($admin_email, $subject, $message); }
Update post meta on unstuck
Update the post meta when a post is unstuck.
add_action('post_unstuck', 'update_post_meta_on_unstuck', 10, 1); function update_post_meta_on_unstuck($post_id) { update_post_meta($post_id, '_unstuck', true); }
Remove category from unstuck post
Remove a specific category when a post is unstuck.
add_action('post_unstuck', 'remove_category_from_unstuck_post', 10, 1); function remove_category_from_unstuck_post($post_id) { $category_to_remove = 'example-category-slug'; wp_remove_object_terms($post_id, $category_to_remove, 'category'); }
Schedule an event after post is unstuck
Schedule a custom event to run after a post has been unstuck.
add_action('post_unstuck', 'schedule_event_after_unstuck', 10, 1); function schedule_event_after_unstuck($post_id) { $timestamp = time() + 3600; // Schedule event for 1 hour later wp_schedule_single_event($timestamp, 'custom_unstuck_event', array($post_id)); }