Advertisement
bennyp

Untitled

Dec 14th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. function events_only_in_home_loop( $query ) {
  2.  
  3.  if ( is_home() && $query->is_main_query() ) // make sure to only run on home page
  4. //attempted resolution from http://www.billerickson.net/customize-the-wordpress-query/
  5. /*
  6.     $meta_query = array(
  7.         array(
  8.             'key' => 'start',
  9.             'value' => time(),
  10.             'compare' => '>'
  11.          )
  12.     );
  13.     $query->set( 'meta_query', $meta_query );
  14.     $query->set( 'orderby', 'meta_value_num' );
  15.     $query->set( 'meta_key', 'start' );
  16.     $query->set( 'order', 'DESC' );
  17. */
  18.  
  19.     $query->set( 'post_type', 'ai1ec_event' ); // select only event post type
  20.  return $query;
  21.  }
  22.  
  23.  add_filter( 'pre_get_posts', 'events_only_in_home_loop' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement