質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -303,3 +303,241 @@
|
|
303
303
|
?>
|
304
304
|
|
305
305
|
```
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
追記
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
下記の場合
|
316
|
+
|
317
|
+
上から順に押していけば絞り込めますが、
|
318
|
+
|
319
|
+
下から順位押した場合は表示が消えてしまいます。
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
```php
|
326
|
+
|
327
|
+
<?php
|
328
|
+
|
329
|
+
$args = array(
|
330
|
+
|
331
|
+
'post_type' => 'post',
|
332
|
+
|
333
|
+
'post_status' => 'publish',
|
334
|
+
|
335
|
+
'posts_per_page' => -1,
|
336
|
+
|
337
|
+
'orderby' => 'date',
|
338
|
+
|
339
|
+
'order' => 'DESC'
|
340
|
+
|
341
|
+
);
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
if (!empty($_POST['search_age'])) {
|
346
|
+
|
347
|
+
foreach ($_POST['search_age'] as $value) {
|
348
|
+
|
349
|
+
$search_age[] = htmlspecialchars($value, ENT_QUOTES);
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
foreach ($_POST['search_place'] as $value) {
|
354
|
+
|
355
|
+
$search_place[] = htmlspecialchars($value, ENT_QUOTES);
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
foreach ($_POST['search_level'] as $value) {
|
360
|
+
|
361
|
+
$search_level[] = htmlspecialchars($value, ENT_QUOTES);
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
$args += array('tax_query' => array(
|
366
|
+
|
367
|
+
'relation' => 'AND',
|
368
|
+
|
369
|
+
array(
|
370
|
+
|
371
|
+
'taxonomy' => 'place',
|
372
|
+
|
373
|
+
'terms' => $search_place,
|
374
|
+
|
375
|
+
'field' => 'term_id',
|
376
|
+
|
377
|
+
'operator' => 'AND'
|
378
|
+
|
379
|
+
),
|
380
|
+
|
381
|
+
array(
|
382
|
+
|
383
|
+
'taxonomy' => 'level',
|
384
|
+
|
385
|
+
'terms' => $search_level,
|
386
|
+
|
387
|
+
'field' => 'term_id',
|
388
|
+
|
389
|
+
'operator' => 'AND'
|
390
|
+
|
391
|
+
),
|
392
|
+
|
393
|
+
array(
|
394
|
+
|
395
|
+
'taxonomy' => 'age',
|
396
|
+
|
397
|
+
'terms' => $search_age,
|
398
|
+
|
399
|
+
'field' => 'term_id',
|
400
|
+
|
401
|
+
'operator' => 'IN'
|
402
|
+
|
403
|
+
)
|
404
|
+
|
405
|
+
));
|
406
|
+
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
if (!empty($_POST['search_place'])) {
|
414
|
+
|
415
|
+
foreach ($_POST['search_age'] as $value) {
|
416
|
+
|
417
|
+
$search_age[] = htmlspecialchars($value, ENT_QUOTES);
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
foreach ($_POST['search_place'] as $value) {
|
422
|
+
|
423
|
+
$search_place[] = htmlspecialchars($value, ENT_QUOTES);
|
424
|
+
|
425
|
+
}
|
426
|
+
|
427
|
+
foreach ($_POST['search_level'] as $value) {
|
428
|
+
|
429
|
+
$search_level[] = htmlspecialchars($value, ENT_QUOTES);
|
430
|
+
|
431
|
+
}
|
432
|
+
|
433
|
+
$args += array('tax_query' => array(
|
434
|
+
|
435
|
+
'relation' => 'AND',
|
436
|
+
|
437
|
+
array(
|
438
|
+
|
439
|
+
'taxonomy' => 'age',
|
440
|
+
|
441
|
+
'terms' => $search_age,
|
442
|
+
|
443
|
+
'field' => 'term_id',
|
444
|
+
|
445
|
+
'operator' => 'AND'
|
446
|
+
|
447
|
+
),
|
448
|
+
|
449
|
+
array(
|
450
|
+
|
451
|
+
'taxonomy' => 'level',
|
452
|
+
|
453
|
+
'terms' => $search_level,
|
454
|
+
|
455
|
+
'field' => 'term_id',
|
456
|
+
|
457
|
+
'operator' => 'AND'
|
458
|
+
|
459
|
+
),
|
460
|
+
|
461
|
+
array(
|
462
|
+
|
463
|
+
'taxonomy' => 'place',
|
464
|
+
|
465
|
+
'terms' => $search_place,
|
466
|
+
|
467
|
+
'field' => 'term_id',
|
468
|
+
|
469
|
+
'operator' => 'IN'
|
470
|
+
|
471
|
+
)
|
472
|
+
|
473
|
+
));
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
if (!empty($_POST['search_level'])) {
|
480
|
+
|
481
|
+
foreach ($_POST['search_age'] as $value) {
|
482
|
+
|
483
|
+
$search_age[] = htmlspecialchars($value, ENT_QUOTES);
|
484
|
+
|
485
|
+
}
|
486
|
+
|
487
|
+
foreach ($_POST['search_place'] as $value) {
|
488
|
+
|
489
|
+
$search_place[] = htmlspecialchars($value, ENT_QUOTES);
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
foreach ($_POST['search_level'] as $value) {
|
494
|
+
|
495
|
+
$search_level[] = htmlspecialchars($value, ENT_QUOTES);
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
$args += array('tax_query' => array(
|
500
|
+
|
501
|
+
'relation' => 'AND',
|
502
|
+
|
503
|
+
array(
|
504
|
+
|
505
|
+
'taxonomy' => 'level',
|
506
|
+
|
507
|
+
'terms' => $search_level,
|
508
|
+
|
509
|
+
'field' => 'term_id',
|
510
|
+
|
511
|
+
'operator' => 'IN'
|
512
|
+
|
513
|
+
),
|
514
|
+
|
515
|
+
array(
|
516
|
+
|
517
|
+
'taxonomy' => 'place',
|
518
|
+
|
519
|
+
'terms' => $search_place,
|
520
|
+
|
521
|
+
'field' => 'term_id',
|
522
|
+
|
523
|
+
'operator' => 'AND'
|
524
|
+
|
525
|
+
),
|
526
|
+
|
527
|
+
array(
|
528
|
+
|
529
|
+
'taxonomy' => 'age',
|
530
|
+
|
531
|
+
'terms' => $search_age,
|
532
|
+
|
533
|
+
'field' => 'term_id',
|
534
|
+
|
535
|
+
'operator' => 'AND'
|
536
|
+
|
537
|
+
),
|
538
|
+
|
539
|
+
));
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
```
|
1
要点を追加
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
カスタムタクソノミーの絞り込み条件の記述がわからない
|
1
|
+
同じカスタムタクソノミーの絞り込み条件の記述がわからない
|
test
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
**要点をまとめますと、同じカスタムタクソノミーを複数選択した時の挙動を修正したいです。
|
2
|
+
|
3
|
+
全て選択すると消えてしまいます。**
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
1
9
|
WordpressでCustom Post Type UIというプラグインで複数のカスタムタクソノミーを作成しまして、
|
2
10
|
|
3
11
|
それを使って絞り込み検索を作成してみました。
|