Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 14, 2012 19:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/4583089b8fdb8694fe30 to your computer and use it in GitHub Desktop.
Save billerickson/4583089b8fdb8694fe30 to your computer and use it in GitHub Desktop.
<?php
/**
* Include products in the blog homepage
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query
*
* @param object $query
*/
function be_blog_query( $query ) {
if( $query->is_main_query() && $query->is_home() && !is_admin() )
$query->set( 'post_type', array( 'post', 'products' ) );
}
add_action( 'pre_get_posts', 'be_blog_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment