# Bulk Make Posts Sticky or Not Sticky

> Adds "Make sticky" and "Remove sticky" to the bulk actions on the Posts screen, so you can pin or unpin many posts at once instead of editing each one.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: bulk-actions, sticky-posts, posts
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-bulk-stick-unstick/

## Code

```php
add_filter( 'bulk_actions-edit-post', function ( $actions ) {
    if ( current_user_can( 'edit_others_posts' ) ) {
        $actions['wpide_stick']   = 'Make sticky';
        $actions['wpide_unstick'] = 'Remove sticky';
    }
    return $actions;
} );

add_filter( 'handle_bulk_actions-edit-post', function ( $redirect, $action, $post_ids ) {
    if ( ! in_array( $action, array( 'wpide_stick', 'wpide_unstick' ), true ) || ! current_user_can( 'edit_others_posts' ) ) {
        return $redirect;
    }

    foreach ( $post_ids as $post_id ) {
        if ( current_user_can( 'edit_post', $post_id ) ) {
            'wpide_stick' === $action ? stick_post( $post_id ) : unstick_post( $post_id );
        }
    }

    return add_query_arg( 'wpide_sticky_done', count( $post_ids ), $redirect );
}, 10, 3 );

add_action( 'admin_notices', function () {
    if ( ! empty( $_GET['wpide_sticky_done'] ) ) {
        printf( '<div class="notice notice-success is-dismissible"><p>Updated sticky status of %d posts.</p></div>', absint( $_GET['wpide_sticky_done'] ) );
    }
} );
```

## Notes

Sticky posts show first on the blog page in most themes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Bulk Make Posts Sticky or Not Sticky" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
