質問編集履歴
1
search.phpに書いてあるコード全部載せました。 以下がfunctions.phpです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,15 @@
|
|
14
14
|
|
15
15
|
//search.php
|
16
16
|
|
17
|
+
<?php get_header('info'); ?>
|
18
|
+
|
19
|
+
<main>
|
20
|
+
|
21
|
+
<article class="articleWrap">
|
22
|
+
|
23
|
+
|
24
|
+
|
17
|
-
<section class="section">
|
25
|
+
<section class="section">
|
18
26
|
|
19
27
|
<h1><?php printf( __( 'Search Results for: %s', 'altitude' ), '<span>' . get_search_query() . '</span>' ); ?>の検索結果</h1>
|
20
28
|
|
@@ -82,7 +90,17 @@
|
|
82
90
|
|
83
91
|
</div>
|
84
92
|
|
85
|
-
</section>
|
93
|
+
</section>
|
94
|
+
|
95
|
+
<?php get_sidebar(); ?>
|
96
|
+
|
97
|
+
</article>
|
98
|
+
|
99
|
+
</main>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<?php get_footer(); ?>
|
86
104
|
|
87
105
|
|
88
106
|
|
@@ -121,3 +139,35 @@
|
|
121
139
|
|
122
140
|
|
123
141
|
よろしくお願いいたします。
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
=============================追記=============================
|
146
|
+
|
147
|
+
上記にsearch.phpに書いてあるコード全部載せました。
|
148
|
+
|
149
|
+
以下がfunctions.phpです。
|
150
|
+
|
151
|
+
```php
|
152
|
+
|
153
|
+
//functions.php
|
154
|
+
|
155
|
+
//検索結果に投稿記事のみを表示する
|
156
|
+
|
157
|
+
function custom_search_result($query) {
|
158
|
+
|
159
|
+
if(!$query->is_admin && $query->is_main_query() && $query->is_search) {
|
160
|
+
|
161
|
+
$query->set('post_type', 'post');
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
return $query;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
add_filter('pre_get_posts','custom_search_result');
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
```
|