Wp_get_archives() controls the display of monthly archives, amongst other things. It may be important to display not only regular posts, but also your custom post types in your monthly archive pages. Add this code snippet to your functions.php file.
|
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', '[my-custom-post]' ) ); $post_types = "'" . implode( "' , '" , $post_types ) . "'"; return str_replace( "post_type = 'post'" , "post_type IN ( $post_types )" , $where ); } |
… Continued