Skip to content

Instantly share code, notes, and snippets.

@jmdodd
Created January 28, 2012 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmdodd/1695498 to your computer and use it in GitHub Desktop.
Save jmdodd/1695498 to your computer and use it in GitHub Desktop.
Add custom post types to the Loop (doing it wrong)
<?php
if ( ! function_exists( 'ucc_request_filter' ) ) {
function ucc_request_filter( $query ) {
// Preview does not like having post_type set; feed is my personal preference.
if ( empty( $query['preview'] ) && empty( $query['feed'] ) ) {
$my_post_type = $query['post_type'];
if ( empty( $my_post_type ) ) {
$query['post_type'] = 'any';
}
}
return $query;
} }
add_filter( 'request' , 'ucc_request_filter' );
/*
Copyright 2012 Jennifer M. Dodd <jmdodd@gmail.com>
Released under the GPLv2 (or later).
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment