やりたいこと
ブログテーマ「swell」を使用して、カスタム投稿タイプのサイドバーに月別アーカイブの表示をしたい。
/**
* ウィジェット「アーカイブ」にフィルター
* require Custom Post Type Permalinks
*/
add_filter( 'widget_archives_args', 'my_widget_archives_args', 10, 1);
add_filter( 'widget_archives_dropdown_args', 'my_widget_archives_args', 10, 1);
function my_widget_archives_args( $args ){
if ( ! is_admin() ) {
if ( 'blog' == get_post_type() ) {
$args['post_type'] = 'blog';
}
}
return $args;
}
参考:https://nldot.info/steps-to-deploy-an-archive-widget-for-a-custom-post-type/
一日探してやっと辿り着いた情報なので、忘れた時用にメモしました🙏