Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么方法可以注册到 wordpress 事件吗? 我想知道帖子何时在系统中更新或创建,并获取其 ID。 可能吗? 谢谢
您可以使用保存帖子挂钩。它在帖子创建和更新时触发。
这是一个示例。
function post_hook( $post_id ) { if ( wp_is_post_revision( $post_id ) ){ //Post is being updated } else { //Post is being created } } add_action( 'save_post', 'post_hook' );
这是来自法典的链接。
保存发布 WP