Given a link like this: http://siteexample.com/2011/04/ I get a 404 not found page if there are only custom posts to show and no normal posts.
This is because, by default, wordpress looks only for normal posts. I tried this:
add_filter( 'getarchives_where' , 'ucc_getarchives_where_filter' , 10 , 2 );
function ucc_getarchives_where_filter( $where , $r ) {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'names';
$operator = 'and';
$post_types = get_post_types( $args , $output , $operator );
$post_types = array_merge( $post_types , array( 'post' ) );
$post_types = "'" . implode( "' , '" , $post_types ) . "'";
return str_replace( "post_type = 'post'" , "post_type IN ( $post_types )" , $where );
}
but this only works when using wp_get_archives (I mean when listing the links).
Are there any hooks so I could be able to modify the main query just before I get 404? Any ideas?

New Topic/Question
Reply


MultiQuote


|