Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'pre_get_posts', 'exclude_author_from_homepage' );
- function exclude_author_from_homepage( $query ) {
- global $wp_the_query; // Stores a copy of the main query
- if (
- $query === $wp_the_query // Is this the main query we're on?
- && $query->is_home() // Homepage only, not single posts, etc.
- ) {
- $query->set( 'author', -123 ); // Exclude author ID 123
- }
- // No need to return anything because this is an action not a filter.
- // The variable passed to this function is done so via a reference.
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement