pre_get_posts
which change the query vars just before the main query is executed.
Here is an example from the codex to exclude categories from the home page/blog page. For a full list of available parameters and values that you can use with pre_get_posts
, visit the WP_Query
codex page:
[php]function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-1,-1347' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );[/php]
Revisions
- June 3, 2015 @ 06:18:43 [Current Revision] by PeterLugg
- June 3, 2015 @ 06:18:43 by PeterLugg
- June 3, 2015 @ 06:18:13 by PeterLugg
Revision Differences
There are no differences between the June 3, 2015 @ 06:18:43 revision and the current revision. (Maybe only post meta information was changed.)
No comments yet.