回答編集履歴

1

コードを追記

2018/08/04 14:30

投稿

yhg
yhg

スコア2161

test CHANGED
@@ -23,3 +23,29 @@
23
23
  ));
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ ## 追記
30
+
31
+
32
+
33
+ ```php
34
+
35
+ <?php
36
+
37
+ function archives_pre_get_posts( $query ) {
38
+
39
+ if ( $query->is_year() && $query->is_main_query() ) {
40
+
41
+ $query->set( 'post_type', array( 'example-1', 'example-2', 'example-3' ) );
42
+
43
+ $query->set( 'showposts', -1 );
44
+
45
+ }
46
+
47
+ }
48
+
49
+ add_action( 'pre_get_posts', 'archives_pre_get_posts' );
50
+
51
+ ```