Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

WordPress hook directory
pre_get_posts

Description

Runs before a query is executed in the main query or any instance of WP_Query, such as query_posts, get_posts, or get_children. This hook is called after the query variable object is created, but before the query is actually run, and can be used to to alter the primary query before it is run. Also see is_main_query. Action function arguments: WP_Query object by reference.

This description was scraped automatically from the WordPress filter reference or action reference. If it looks like this is the wrong description, please tell me so I can fix my code.

WordPress version history for pre_get_posts

This database has information for all major versions from WP 1.2.1 through 6.2.

Version File Line Type
2.0 wp-includes/classes.php 262 View in context action
2.0.11 wp-includes/classes.php 272 View in context action
2.1 wp-includes/query.php 573 View in context action
2.2 wp-includes/query.php 643 View in context action
2.3 wp-includes/query.php 733 View in context action
2.5 wp-includes/query.php 811 View in context action
2.6 wp-includes/query.php 815 View in context action
2.7 wp-includes/query.php 1565 View in context action
2.8 wp-includes/query.php 1567 View in context action
2.9 wp-includes/query.php 1549 View in context action
3.0 wp-includes/query.php 1611 View in context action
3.1 wp-includes/query.php 1877 View in context action
3.2 wp-includes/query.php 1911 View in context action
3.3 wp-includes/query.php 1923 View in context action
3.4 wp-includes/query.php 1922 View in context action
3.5 wp-includes/query.php 1924 View in context action
3.6 wp-includes/query.php 1924 View in context action
3.7 wp-includes/query.php 2139 View in context action
3.8 wp-includes/query.php 2154 View in context action
3.9 wp-includes/query.php 2186 View in context action
4.0 wp-includes/query.php 2369 View in context action
4.1 wp-includes/query.php 2377 View in context action
4.2 wp-includes/query.php 2396 View in context action
4.3 wp-includes/query.php 2402 View in context action
4.4 wp-includes/query.php 2516 View in context action
4.5 wp-includes/query.php 2493 View in context action
4.6 wp-includes/query.php 2503 View in context action
4.7 wp-includes/class-wp-query.php 1681 View in context action
4.8 wp-includes/class-wp-query.php 1683 View in context action
4.9 wp-includes/class-wp-query.php 1634 View in context action
5.0 wp-includes/class-wp-query.php 1634 View in context action
5.1 wp-includes/class-wp-query.php 1736 View in context action
5.2 wp-includes/class-wp-query.php 1753 View in context action
5.3 wp-includes/class-wp-query.php 1757 View in context action
5.4 wp-includes/class-wp-query.php 1772 View in context action
5.5 wp-includes/class-wp-query.php 1779 View in context action
5.6 wp-includes/class-wp-query.php 1779 View in context action
5.7 wp-includes/class-wp-query.php 1784 View in context action
5.8 wp-includes/class-wp-query.php 1784 View in context action
5.9 wp-includes/class-wp-query.php 1804 View in context action
6.0 wp-includes/class-wp-query.php 1805 View in context action
6.1 wp-includes/class-wp-query.php 1833 View in context action
6.2 wp-includes/class-wp-query.php 1870 View in context action

Related Hooks

We find related hooks using word stems. pre_get_posts has 1 significant word stem(s): posts. Note that some of the hooks below may not appear in all versions of WP.