钩子文档

post_stuck

💡 云策文档标注

概述

post_stuck 是一个 WordPress 动作钩子,在文章被添加到置顶列表时触发。它主要用于开发者监听文章置顶事件,并执行自定义操作。

关键要点

  • 触发时机:当文章被添加到置顶列表时立即触发
  • 参数:$post_id(整数),表示被置顶的文章ID
  • 源调用:do_action( 'post_stuck', $post_id )
  • 相关函数:stick_post() 用于将文章置顶
  • 版本历史:从 WordPress 4.6.0 版本引入

📄 原文内容

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

Parameters

$post_idint
ID of the post that was stuck.

Source

do_action( 'post_stuck', $post_id );

Changelog

Version Description
4.6.0 Introduced.