https://developer.wordpress.org/reference/classes/wp_widget_archives/
によると、
ウェジットでドロップダウン形式を選択していないならば、
PHP
1wp_get_archives(
2 apply_filters(
3 'widget_archives_args',
4 array(
5 'type' => 'monthly',
6 'show_post_count' => $c,
7 ),
8 $instance
9 )
10);
wp_get_archivesを読みだしてるだけですね。
https://elearn.jp/wpman/function/wp_get_archives.html
によると、wp_get_archivesは引数にpost_typeを追加できるので、こうすればよいかと。
PHP
1//functions.phpに追記
2add_filter( 'widget_archives_args','my_topics_archives');
3function my_topics_archives( $content ){
4 $content['post_type'] = 'topics';
5 return $content;
6}
でもこのままだと他の投稿タイプのページで月別アーカイブウェジットを使おうとしてもtopicsのリンクが出そうなので、これで行けるかな。get_post_type()がちゃんと働くのか確認してないのでもしだめなら上記の奴で許して。
PHP
1//functions.phpに追記
2add_filter( 'widget_archives_args','my_topics_archives');
3function my_topics_archives( $content ){
4
5 //topics, post投稿タイプのページではそれぞれの投稿タイプの月別アーカイブにする。
6 //ここら辺のifの判定内容については、状況によって書き換えてください。例:if( is_home() )
7 if( in_array( $post_type = get_post_type(), array( 'topics', 'post' ) ) ){
8 $content['post_type'] = $post_type;
9 }
10
11 return $content;
12}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/06 04:09
2019/08/06 04:30
2019/08/08 00:12
2019/08/23 05:13