質問編集履歴
1
写真、コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -170,12 +170,372 @@
|
|
170
170
|
|
171
171
|
```
|
172
172
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
http
|
173
|
+
```
|
174
|
+
|
175
|
+
search.php
|
176
|
+
|
177
|
+
<section class="section section-project">
|
178
|
+
|
179
|
+
<h2 class="section-title section-title__project">
|
180
|
+
|
181
|
+
<img src="<?php echo get_template_directory_uri(); ?>/img/common/project-title@144x-8.png" alt="project">
|
182
|
+
|
183
|
+
</h2>
|
184
|
+
|
185
|
+
<div class="s-btn">
|
186
|
+
|
187
|
+
<span>
|
188
|
+
|
189
|
+
search
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
</div>
|
194
|
+
|
195
|
+
<?php get_search_form(); ?>
|
196
|
+
|
197
|
+
<div class="project-wrapper">
|
198
|
+
|
199
|
+
<ul class="project-list">
|
200
|
+
|
201
|
+
<?php
|
202
|
+
|
203
|
+
$service_terms_pros = get_terms('service',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=>'0' )); //親タームを取得
|
204
|
+
|
205
|
+
foreach($service_terms_pros as $service_term_pros){
|
206
|
+
|
207
|
+
$service_terms[] = $service_term_pros;
|
208
|
+
|
209
|
+
$service_terms_elems = get_terms('service',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=> $service_term_pros->term_id )); //子タームを取得
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
foreach ($service_terms_elems as $service_terms_elem){
|
214
|
+
|
215
|
+
$service_terms[] = $service_terms_elem;
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
$service = array();
|
224
|
+
|
225
|
+
$services = array();
|
226
|
+
|
227
|
+
$service_selected = array();
|
228
|
+
|
229
|
+
$services = isset($_GET['service']) ? ($_GET['service']) : null;
|
230
|
+
|
231
|
+
if($services){
|
232
|
+
|
233
|
+
foreach($services as $value){ //get値がある場合は該当項目をセット
|
234
|
+
|
235
|
+
$service[]=htmlspecialchars($value);
|
236
|
+
|
237
|
+
$service_selected[]=htmlspecialchars($value);
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
}else{
|
242
|
+
|
243
|
+
foreach($service_terms as $service_term){ //get値がない場合は全項目をセット
|
244
|
+
|
245
|
+
$service[] = $service_term->slug;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
$category_terms_pros = get_terms('categorytag',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=>'0' )); //親タームを取得
|
256
|
+
|
257
|
+
foreach($category_terms_pros as $category_term_pros){
|
258
|
+
|
259
|
+
$category_terms[] = $category_term_pros;
|
260
|
+
|
261
|
+
$category_terms_elems = get_terms('categorytag',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=> $category_term_pros->term_id )); //子タームを取得
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
foreach ($category_terms_elems as $category_terms_elem){
|
266
|
+
|
267
|
+
$category_terms[] = $category_terms_elem;
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
$category = array();
|
276
|
+
|
277
|
+
$categories = array();
|
278
|
+
|
279
|
+
$category_selected = array();
|
280
|
+
|
281
|
+
$categories = isset($_GET['category']) ? ($_GET['category']) : null;
|
282
|
+
|
283
|
+
if($categories){
|
284
|
+
|
285
|
+
foreach($categories as $value02){ //get値がある場合は該当項目をセット
|
286
|
+
|
287
|
+
$category[]=htmlspecialchars($value02);
|
288
|
+
|
289
|
+
$category_selected[]=htmlspecialchars($value02);
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
}else{
|
294
|
+
|
295
|
+
foreach($category_terms as $category_term){ //get値がない場合は全項目をセット
|
296
|
+
|
297
|
+
$category[] = $category_term->slug;
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
$people_terms_pros = get_terms('people',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=>'0' )); //親タームを取得
|
308
|
+
|
309
|
+
foreach($people_terms_pros as $people_term_pros){
|
310
|
+
|
311
|
+
$people_terms[] = $people_term_pros;
|
312
|
+
|
313
|
+
$people_terms_elems = get_terms('people',array( 'orderby' => 'term_order','order' => 'ASC', 'parent'=> $people_term_pros->term_id )); //子タームを取得
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
foreach ($people_terms_elems as $people_terms_elem){
|
318
|
+
|
319
|
+
$people_terms[] = $people_terms_elem;
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
$people = array();
|
328
|
+
|
329
|
+
$peoples = array();
|
330
|
+
|
331
|
+
$people_selected = array();
|
332
|
+
|
333
|
+
$peoples = isset($_GET['people']) ? ($_GET['people']) : null;
|
334
|
+
|
335
|
+
if($peoples){
|
336
|
+
|
337
|
+
foreach($peoples as $value03){ //get値がある場合は該当項目をセット
|
338
|
+
|
339
|
+
$people[]=htmlspecialchars($value03);
|
340
|
+
|
341
|
+
$people_selected[]=htmlspecialchars($value03);
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
}else{
|
346
|
+
|
347
|
+
foreach($people_terms as $people_term){ //get値がない場合は全項目をセット
|
348
|
+
|
349
|
+
$people[] = $people_term->slug;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
|
360
|
+
|
361
|
+
$the_query = new WP_Query( array(
|
362
|
+
|
363
|
+
'post_status' => 'publish',
|
364
|
+
|
365
|
+
'post_type' => 'works',
|
366
|
+
|
367
|
+
'tax_query' => array(
|
368
|
+
|
369
|
+
'relation' => 'AND',
|
370
|
+
|
371
|
+
array(
|
372
|
+
|
373
|
+
'taxonomy' => 'service',
|
374
|
+
|
375
|
+
'field' => 'slug',
|
376
|
+
|
377
|
+
'terms' => $service,
|
378
|
+
|
379
|
+
),
|
380
|
+
|
381
|
+
array(
|
382
|
+
|
383
|
+
'taxonomy' => 'categorytag',
|
384
|
+
|
385
|
+
'field' => 'slug',
|
386
|
+
|
387
|
+
'terms' => $category,
|
388
|
+
|
389
|
+
),
|
390
|
+
|
391
|
+
array(
|
392
|
+
|
393
|
+
'taxonomy' => 'people',
|
394
|
+
|
395
|
+
'field' => 'slug',
|
396
|
+
|
397
|
+
'terms' => $people,
|
398
|
+
|
399
|
+
),
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
),
|
404
|
+
|
405
|
+
'paged' => $paged,
|
406
|
+
|
407
|
+
'posts_per_page' => -1, // 表示件数
|
408
|
+
|
409
|
+
'orderby' => 'date',
|
410
|
+
|
411
|
+
'order' => 'DESC',
|
412
|
+
|
413
|
+
) );
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
if ($the_query->have_posts()) :
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
while ($the_query->have_posts()) : $the_query->the_post();
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
$service_label = get_taxonomy( 'service' )->label;
|
426
|
+
|
427
|
+
$service_arr = wp_get_object_terms($post->ID, 'service',array( 'orderby' => 'term_order' ));
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
$category_label = get_taxonomy( 'categorytag' )->label;
|
432
|
+
|
433
|
+
$category_arr = wp_get_object_terms($post->ID, 'categorytag',array( 'orderby' => 'term_order' ));
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
$people_label = get_taxonomy( 'people' )->label;
|
438
|
+
|
439
|
+
$people_arr = wp_get_object_terms($post->ID, 'people',array( 'orderby' => 'term_order' ));
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
?>
|
444
|
+
|
445
|
+
<li class="project-listItem">
|
446
|
+
|
447
|
+
<a href="<?php the_permalink(); ?>">
|
448
|
+
|
449
|
+
<div class="project-img">
|
450
|
+
|
451
|
+
<div style="background-image:url('<?php
|
452
|
+
|
453
|
+
$image = get_field('kv');
|
454
|
+
|
455
|
+
if( !empty($image) ){
|
456
|
+
|
457
|
+
echo $image['sizes'][ "medium" ];
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
?>')"></div>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
<p class="project-meta">
|
466
|
+
|
467
|
+
<?php the_time('Y.m.d'); ?>
|
468
|
+
|
469
|
+
</p>
|
470
|
+
|
471
|
+
<h3 class="project-title">
|
472
|
+
|
473
|
+
<span><?php the_title(); ?></span>
|
474
|
+
|
475
|
+
</h3>
|
476
|
+
|
477
|
+
</a>
|
478
|
+
|
479
|
+
<ul class="meta-list meta-list__project">
|
480
|
+
|
481
|
+
<?php
|
482
|
+
|
483
|
+
$works_url = get_post_type_archive_link('works');
|
484
|
+
|
485
|
+
foreach(['service', 'categorytag', 'people'] as $tax){
|
486
|
+
|
487
|
+
$terms = get_the_terms($post->ID, $tax);
|
488
|
+
|
489
|
+
foreach( $terms as $term ) {
|
490
|
+
|
491
|
+
echo '<li><a href="'.$works_url.'?s='.urlencode($tax.','.$term->slug).'">'.$term->name.'</a></li>';
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
}
|
496
|
+
|
497
|
+
?>
|
498
|
+
|
499
|
+
</ul>
|
500
|
+
|
501
|
+
<a href="<?php the_permalink(); ?>" class="btn btn-project btn-more">
|
502
|
+
|
503
|
+
<span>more</span>
|
504
|
+
|
505
|
+
</a>
|
506
|
+
|
507
|
+
</li>
|
508
|
+
|
509
|
+
<?php endwhile;
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
else :?>
|
514
|
+
|
515
|
+
<li>
|
516
|
+
|
517
|
+
<p>
|
518
|
+
|
519
|
+
条件に合致する記事はありません
|
520
|
+
|
521
|
+
</p>
|
522
|
+
|
523
|
+
</li>
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
<?php endif;?>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
</ul>
|
532
|
+
|
533
|
+
</div>
|
534
|
+
|
535
|
+
</section>
|
536
|
+
|
537
|
+
```
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
![イメージ説明](db1223f9c9f38293d3adbbbe7e49b53f.png)
|