pre_get_posts action-hook . WP 2.0.0
Fires after the query variable object is created, but before the actual query is run.
Note: If using conditional tags, use the method versions within the passed instance (e.g. $this->is_main_query() instead of is_main_query()). This is because the functions like is_main_query() test against the global $wp_query instance, not the passed one.
Usage
add_action( 'pre_get_posts', 'action_function_name_7841' ); function action_function_name_7841( $this ){ // action... }
- $this(WP_Query)
- The WP_Query instance (passed by reference).
Changelog
Since 2.0.0 | Introduced. |
Where the hook is called
pre_get_posts
wp-includes/class-wp-query.php 1779
do_action_ref_array( 'pre_get_posts', array( &$this ) );