[wp-hackers] 'request' filter for adding custom post types to blog indexes

Krusty Ruffle krustyruffle at rustykruffle.com
Wed Aug 11 18:11:20 UTC 2010


I'm wanting to add a custom post type to the main blog index, the author
index and the date indexes. Can anybody tell me if this will cause problems
or if there is a better way to do it?

add_filter ( 'request', 'my_request' ) ;
function my_request ( $request ) {
     // Check for proper indexes. An empty $request means we are on the main
blog index.
     if ( empty ( $request ) || isset ( $request['author_name'] ) || isset (
$request['year'] ) )
          $request['post_type'] = array ( 'post', 'my_post_type' ) ; //
Modify the $request
     return $request ;
}


More information about the wp-hackers mailing list