質問編集履歴

2

コードの変更

2018/10/19 07:56

投稿

KyokoKawamoto
KyokoKawamoto

スコア14

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
  <ul>
36
36
 
37
- <?php wp_list_categories(array('title_li' => '', 'post_type' => 'blog', 'show_count' => 0, 'depth' => 1)); ?>
37
+     <?php wp_list_categories('title_li=&depth=1'); ?>
38
38
 
39
39
  </ul>
40
40
 

1

追記

2018/10/19 07:56

投稿

KyokoKawamoto
KyokoKawamoto

スコア14

test CHANGED
File without changes
test CHANGED
@@ -39,3 +39,47 @@
39
39
  </ul>
40
40
 
41
41
  ```
42
+
43
+
44
+
45
+ ```PHP
46
+
47
+
48
+
49
+ function change_posts_per_page($query) {
50
+
51
+ if ( is_admin() || ! $query->is_main_query() ){
52
+
53
+ return;
54
+
55
+ }
56
+
57
+
58
+
59
+ /* カテゴリーページ カスタム投稿を含める */
60
+
61
+ if ( $query->is_category() ) {
62
+
63
+ $query->set( 'post_type',array('post','blog' ));
64
+
65
+ return;
66
+
67
+ }
68
+
69
+ /* 検索一覧ページ カスタム投稿を含める */
70
+
71
+ if( $query->is_search() ){
72
+
73
+ $query->set( 'post_type',array( 'post','blog' ));
74
+
75
+ return;
76
+
77
+ }
78
+
79
+ }
80
+
81
+ add_action( 'pre_get_posts', 'change_posts_per_page' );
82
+
83
+
84
+
85
+ ```