do_action_ref_array( 'the_post', WP_Post $post, WP_Query $this )

Fires once the post data has been setup.


Description Description


Parameters Parameters

$post

(WP_Post) The Post object (passed by reference).

$this

(WP_Query) The current Query object (passed by reference).


Top ↑

Source Source

File: wp-includes/class-wp-query.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
4.1.0 Introduced $this parameter.
2.8.0 Introduced.

Top ↑

More Information More Information

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.

Top ↑

Example Example


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



Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.