Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 15, 2012 14:59
Show Gist options
  • Save billerickson/1616098 to your computer and use it in GitHub Desktop.
Save billerickson/1616098 to your computer and use it in GitHub Desktop.
<?php
add_action( 'pre_get_posts', 'be_listing_type_query' );
/**
* Customize the Listing Type taxonomy query
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
function be_listing_type_query( $query ) {
if( $query->is_main_query() && $query->is_tax( 'otf_listing_type' ) ) {
$meta_query = array(
'key' => '_oft_ad_level',
'value' => 'free',
'compare' => '='
);
$query->set( 'meta_query', $meta_query );
$query->set( 'posts_per_page', '7' );
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment