Advertisement
Viper007Bond

Untitled

Sep 26th, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'pre_get_posts', 'exclude_author_from_homepage' );
  4.  
  5. function exclude_author_from_homepage( $query ) {
  6.     global $wp_the_query; // Stores a copy of the main query
  7.  
  8.     if (
  9.         $query === $wp_the_query // Is this the main query we're on?
  10.         && $query->is_home() // Homepage only, not single posts, etc.
  11.     ) {
  12.         $query->set( 'author', -123 ); // Exclude author ID 123
  13.     }
  14.  
  15.     // No need to return anything because this is an action not a filter.
  16.     // The variable passed to this function is done so via a reference.
  17. }
  18.  
  19. ?>
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement