Include Custom Posts Type in Year/Month/Date Archive

Your code simply adds post types to the query when on the author archive so to do the same with date archive simply replace is_author to is_date :

function custom_post_date_archive($query) {
    if ($query->is_date)
        $query->set( 'post_type', array('wp_plugin_review', 'png_gallery', 'post', 'news') );
    remove_action( 'pre_get_posts', 'custom_post_author_archive' );
}
add_action('pre_get_posts', 'custom_post_date_archive');

Leave a Comment