WP 月別アーカイブにカスタム投稿も含める

functions.php

/**
* 月別アーカイブにカスタム投稿も含める
*/
function my_pre_get_posts( $query ) {
    if ( $query->is_month() && $query->is_main_query() ) {
        $query->set( 'post_type', array('post','wat','design_lab') );
    }
}
add_action( 'pre_get_posts', 'my_pre_get_posts' );

function my_getarchives_where( $where ){
    $where = "WHERE";
    $where .= " (post_type = 'post' OR post_type = 'wat' OR post_type = 'design_lab')";
    $where .= " AND post_status = 'publish'";
    return $where;
}
add_filter( 'getarchives_where', 'my_getarchives_where' );

sidebar-archives.php

<aside class="archive">
    <h2 class="archive_title">月別アーカイブ</h2>
    <ul class="archive_list">
        <?php
        $args = array(
            'type' => 'monthly', //月別を指定
        );
        wp_get_archives( $args );
        ?>
    </ul>
</aside>
'''
あとは読み込みたい場所で
‘‘‘
<?php get_sidebar('archives'); ?>
‘‘‘