Title: stick_post
Published: April 25, 2014
Last modified: February 24, 2026

---

# stick_post( int $post_id )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#wp--skip-link--target)

Makes a post sticky.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#description)󠁿

Sticky posts should be displayed at the top of the front page.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#parameters)󠁿

 `$post_id`intrequired

Post ID.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#source)󠁿

    ```php
    function stick_post( $post_id ) {
    	$post_id  = (int) $post_id;
    	$stickies = get_option( 'sticky_posts' );
    	$updated  = false;

    	if ( ! is_array( $stickies ) ) {
    		$stickies = array();
    	} else {
    		$stickies = array_unique( array_map( 'intval', $stickies ) );
    	}

    	if ( ! in_array( $post_id, $stickies, true ) ) {
    		$stickies[] = $post_id;
    		$updated    = update_option( 'sticky_posts', array_values( $stickies ) );
    	}

    	if ( $updated ) {
    		/**
    		 * Fires once a post has been added to the sticky list.
    		 *
    		 * @since 4.6.0
    		 *
    		 * @param int $post_id ID of the post that was stuck.
    		 */
    		do_action( 'post_stuck', $post_id );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/post.php#L3288)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/post.php#L3288-L3314)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#hooks)󠁿

 [do_action( ‘post_stuck’, int $post_id )](https://developer.wordpress.org/reference/hooks/post_stuck/)

Fires once a post has been added to the sticky list.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#related)󠁿

| Uses | Description | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#)

| Used by | Description | 
| [WP_REST_Posts_Controller::create_item()](https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/create_item/)`wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php` |

Creates a single post.

  | 
| [WP_REST_Posts_Controller::update_item()](https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/update_item/)`wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php` |

Updates a single post.

  | 
| [wp_xmlrpc_server::_toggle_sticky()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/_toggle_sticky/)`wp-includes/class-wp-xmlrpc-server.php` |

Encapsulates the logic for sticking a post and determining if the user has permission to do so.

  | 
| [edit_post()](https://developer.wordpress.org/reference/functions/edit_post/)`wp-admin/includes/post.php` |

Updates an existing post with values provided in `$_POST`.

  | 
| [bulk_edit_posts()](https://developer.wordpress.org/reference/functions/bulk_edit_posts/)`wp-admin/includes/post.php` |

Processes the post data for the bulk editing of posts.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/stick_post/?output_format=md#comment-content-1532)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/stick_post/#comment-1532)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fstick_post%2F%23comment-1532)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fstick_post%2F%23comment-1532)
 4. **Example**
 5.     ```php
        $post_id = 1;
        stick_post( $post_id );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fstick_post%2F%3Freplytocom%3D1532%23feedback-editor-1532)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fstick_post%2F)
before being able to contribute a note or feedback.