Want more features on Pastebin? Sign Up, it's FREE!

The Events Calendar Conflict with is_home() query Mod

By: dpellenwood on Nov 5th, 2012  |  syntax: PHP  |  size: 0.87 KB  |  views: 96  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * Setup the Index page, main query adjustments
  3.  *
  4.  * If we're viewing the site index get the first 5 posts
  5.  * from the "Marquee" category (home-slider), ordered
  6.  * by our meta value and ignoring any sticky stuff.
  7.  *
  8.  */
  9. function mnsu_index_query( $query ) {
  10.     if ( is_home() && $query->is_main_query() ) {
  11.                 // Set paging to 5
  12.                 $query->set( 'posts_per_page', '5' );
  13.                 $query->set( 'ignore_sticky_posts', 1 );
  14.                 // Get posts from the Marquee category
  15.                 $tax_query = array (
  16.                         array(
  17.                                 'taxonomy' => 'placements',
  18.                                 'terms' => array( 'home-slider' ),
  19.                                 'field' => 'slug',
  20.                         )
  21.         );
  22.         $query->set( 'tax_query', $tax_query );
  23.         $query->set( 'meta_key', 'mnsu_placement_home-slider' );
  24.         $query->set( 'orderby', 'meta_value_num' );
  25.         $query->set( 'order', 'ASC' );
  26.     }
  27. }
  28. add_action( 'pre_get_posts', 'mnsu_index_query' );
clone this paste RAW Paste Data