WordPress 挂钩:post 已加载
Wordpress Hook: post loaded
我需要 运行 一个函数,用于在加载 post 时通过 post id 设置一些标签。
加载 post 时,是否有任何钩子可以让我检查 post id?
您要查找的动作挂钩是the_post。此挂钩在 post 对象创建后触发。
快速示例:
<?php
function some_post_action( $post_object ) {
// your function here, use $post_object->ID to access post id
}
add_action( 'the_post', 'some_post_action' );
?>
我需要 运行 一个函数,用于在加载 post 时通过 post id 设置一些标签。 加载 post 时,是否有任何钩子可以让我检查 post id?
您要查找的动作挂钩是the_post。此挂钩在 post 对象创建后触发。
快速示例:
<?php
function some_post_action( $post_object ) {
// your function here, use $post_object->ID to access post id
}
add_action( 'the_post', 'some_post_action' );
?>