Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_stuck action in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
July 28, 2022
5 minutes read

post_stuck action

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

do_action( 'post_stuck', int $post_id )

Description

This action hook fires whenever a post has been added to the sticky list. It consists of one parameter, $post_id, which belongs to the post that was stuck.

Parameters

  • $post_id: (int) ID of the post that was stuck.

Live Examples

Example 1: Running the Hook

To run the hook, you can copy the example below.

do_action( 'post_stuck', int $post_id );

Example 2: Adding a Hook Callback

The following example shows how to add a hook callback.

add_action( 'post_stuck', 'weplugins_post_stuck_action' );

/**
 * Function for `post_stuck` action-hook.
 * 
 * @param int $post_id ID of the post that was stuck.
 *
 * @return void
 */
function weplugins_post_stuck_action( $post_id ){
    // action...
}

Example 3: Removing a Hook Callback

To remove a hook callback, use the example below.

// remove the action
remove_action( 'post_stuck', 'weplugins_post_stuck_action', 10, 1 ); 

Access Premium WordPress Plugins

Contact Us

If you need any customization or have any questions, feel free to contact us.

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.