Skip to content

Instantly share code, notes, and snippets.

@diegolamonica
Created November 11, 2012 10:51
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 diegolamonica/4054526 to your computer and use it in GitHub Desktop.
Save diegolamonica/4054526 to your computer and use it in GitHub Desktop.
Wordpress: Seeking for multiple post types in the loop
<?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