質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -109,3 +109,93 @@
|
|
109
109
|
?>
|
110
110
|
|
111
111
|
```
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
解決していないため、追記します。
|
118
|
+
|
119
|
+
ソースは簡略にしたところこういった感じです。
|
120
|
+
|
121
|
+
```php
|
122
|
+
|
123
|
+
<?php get_header(); ?>
|
124
|
+
|
125
|
+
<p class="search">「<?php the_search_query(); ?>」の検索結果</p>
|
126
|
+
|
127
|
+
<?php
|
128
|
+
|
129
|
+
if (have_posts() && get_search_query()) :
|
130
|
+
|
131
|
+
while (have_posts()) :
|
132
|
+
|
133
|
+
the_post();
|
134
|
+
|
135
|
+
get_template_part('each_exrpt_post');
|
136
|
+
|
137
|
+
endwhile;
|
138
|
+
|
139
|
+
?>
|
140
|
+
|
141
|
+
<div id="post-<?php the_ID(); ?>" class="">
|
142
|
+
|
143
|
+
<div class="section">
|
144
|
+
|
145
|
+
<h4><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_the_title(); ?></a></h4>
|
146
|
+
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<?php if ( $wp_query -> max_num_pages > 1 ) : ?>
|
150
|
+
|
151
|
+
<div class="pager"><?php next_posts_link('« 古い記事'); previous_posts_link('新しい記事 »'); ?></div>
|
152
|
+
|
153
|
+
<?php endif; ?>
|
154
|
+
|
155
|
+
<!-- /pager -->
|
156
|
+
|
157
|
+
<?php else: ?>
|
158
|
+
|
159
|
+
<div class="section">
|
160
|
+
|
161
|
+
<p>お探しの記事は見つかりませんでした。</p>
|
162
|
+
|
163
|
+
</div>
|
164
|
+
|
165
|
+
<?php endif; ?>
|
166
|
+
|
167
|
+
<?php get_sidebar(); ?>
|
168
|
+
|
169
|
+
<?php get_footer(); ?>
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
↑search.php
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
```php
|
178
|
+
|
179
|
+
//function.phpに特定の記事を検索結果に出さないように追記
|
180
|
+
|
181
|
+
function fb_search_filter($query) {
|
182
|
+
|
183
|
+
if ( !$query -> is_admin && $query -> is_search) {
|
184
|
+
|
185
|
+
$query -> set('post__not_in', array(43, 27, 9, 85, 7, 64, 31, 36, 73, 5,) );
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
return $query;
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
add_filter( 'pre_get_posts', 'fb_search_filter' );
|
194
|
+
|
195
|
+
```
|
196
|
+
|
197
|
+
↑functions.php
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
すみません、長々となってしまいましたが助言をください。
|