Skip to content

Instantly share code, notes, and snippets.

@gr4y
Forked from bueltge/gist:998648
Created June 2, 2011 06:39
Show Gist options
  • Save gr4y/1004026 to your computer and use it in GitHub Desktop.
Save gr4y/1004026 to your computer and use it in GitHub Desktop.
Example for add a Custom Post Type to the WordPress Loop
// add custom post type to wp loop
add_filter( 'pre_get_posts', array(&$this, 'add_to_query') );
// ads to query
function add_to_query( $query ) {
if ( is_admin() || is_preview() )
return;
//if ( is_home() || is_front_page() && ( false == $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array( 'post', FB_CPT_POST_TYPE_1 ) );
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment