WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/the post

Description

The 'the_post' action hook allows developers to modify the post object immediately after being queried and setup.

The post object is passed to this hook by reference so there is no need to return a value.

Example

function my_the_post_action( $post_object ) {
	// modify post object here
}
add_action( 'the_post', 'my_the_post_action' );

Source File

'the_post' action is located near the end of the setup_postdata() function in wp-includes/query.php.

Related