Created
January 28, 2012 19:22
-
-
Save jmdodd/1695498 to your computer and use it in GitHub Desktop.
Add custom post types to the Loop (doing it wrong)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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