Created
November 11, 2012 10:51
-
-
Save diegolamonica/4054526 to your computer and use it in GitHub Desktop.
Wordpress: Seeking for multiple post types in the loop
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 | |
add_filter('request', 'myCustomRequest', 0); | |
function myCustomRequest($req){ | |
if(!is_admin()){ | |
/* | |
* In admin context we will ignore it | |
*/ | |
if(!isset($req['page'])){ | |
/* | |
* is it a page or post? | |
*/ | |
/* If the post_type is not set I will assume it's default "post" */ | |
if(!isset($req['post_type'])) $req['post_type'] = array('post'); | |
/* | |
* Then finally I will add the custom type to the selection | |
*/ | |
$req['post_type'][] = 'my-custom-post'; | |
} | |
} | |
return $req; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment