質問編集履歴

2

カスタムフィールドの登録内容の階層を追加しました。

2020/08/18 07:34

投稿

bushclover
bushclover

スコア0

test CHANGED
File without changes
test CHANGED
@@ -34,25 +34,27 @@
34
34
 
35
35
  組合(archive-union.php)
36
36
 
37
- フィールド名:union_info
37
+ フィールド名:union_info
38
-
38
+
39
- フィールドタイプ:Group
39
+ フィールドタイプ:Group
40
+
40
-
41
+ ├サブフィールド
42
+
41
- サブフィールド:union_name
43
+ │ └ 組合名:union_name(テキスト)
42
-
44
+
43
-  住所:union_address(テキスト)
45
+  └ 組合住所:union_address(テキスト)
44
-
46
+
45
-  TEL:union_tel(テキスト)
47
+  └ 組合TEL:union_tel(テキスト)
46
-
48
+
47
-  HP:union_hp(テキスト)
49
+  └ 組合HP:union_hp(テキスト)
48
-
50
+
49
-  会員情報:member_info_list(繰り返しフィールド)
51
+  会員情報:member_info_list(繰り返しフィールド)
50
-
52
+
51
-   会員名:member_name(テキスト)
53
+   会員名:member_name(テキスト)
52
-
54
+
53
-   住所:member_address(テキスト)
55
+   └会員住所:member_address(テキスト)
54
-
56
+
55
-   TEL:member_address(テキスト)
57
+   └会員TEL:member_address(テキスト)
56
58
 
57
59
 
58
60
 

1

codeを一部修正しました。

2020/08/18 07:34

投稿

bushclover
bushclover

スコア0

test CHANGED
File without changes
test CHANGED
@@ -378,44 +378,70 @@
378
378
 
379
379
  </div>
380
380
 
381
+ <?php
382
+
383
+ $repeater = $group['member_info_list'];
384
+
385
+
386
+
387
+ $r = '0';
388
+
389
+ $r_count = count($repeater);
390
+
391
+
392
+
393
+ while($r_count > $r){
394
+
395
+
396
+
397
+ $repeater_content = $repeater[$r];
398
+
381
- <?php if(have_rows('member_info_list')): ?>
399
+ if(get_field('member_info_list')):
382
-
400
+
383
- <?php while(have_rows('member_info_list')): the_row(); ?>
401
+ ?>
384
-
402
+
385
- <dl>
403
+ <dl>
386
-
404
+
387
- <dt><a href="<?php echo get_permalink($tax_post->ID); ?>"><?php the_sub_field('member_name'); ?></a></dt>
405
+ <dt><a href="<?php echo get_permalink($tax_post->ID); ?>"><?php echo $repeater_content['member_name']; ?></a></dt>
388
-
406
+
389
- <dd><?php the_sub_field('member_address'); ?></dd>
407
+ <dd><?php echo $repeater_content['member_address']; ?></dd>
390
-
408
+
391
- <dd><a href="tel:<?php the_sub_field('member_tel'); ?>"><?php the_sub_field('member_tel'); ?></a></dd>
409
+ <dd><a href="tel:<?php echo $repeater_content['member_tel']; ?>"><?php echo $repeater_content['member_tel']; ?></a></dd>
392
-
410
+
393
- </dl>
411
+ </dl>
394
-
412
+
395
- <?php endwhile; ?>
413
+ <?php else: ?>
414
+
396
-
415
+ <p>現在、会員は登録されていません</p>
416
+
397
- <?php endif; ?>
417
+ <?php endif; ?>
418
+
419
+
420
+
421
+ <?php $r++;
422
+
423
+ } ?>
424
+
425
+ </div>
426
+
427
+
428
+
429
+ <?php } ?>
430
+
431
+
432
+
433
+ <?php endforeach; wp_reset_postdata(); ?>
398
434
 
399
435
 
400
436
 
401
- </div>
437
+ <?php if ($r == 0): ?>
438
+
402
-
439
+ <p>現在、会員は登録されていません</p>
440
+
403
- <?php } ?>
441
+ <?php endif; ?>
404
-
405
-
406
-
407
- <?php endforeach; wp_reset_postdata(); ?>
408
442
 
409
443
 
410
444
 
411
- <?php if ($r == 0): ?>
412
-
413
- <p>現在、会員は登録されていません</p>
414
-
415
- <?php endif; ?>
416
-
417
-
418
-
419
445
  <?php } endforeach; endif; ?>
420
446
 
421
447
  ```
@@ -446,6 +472,8 @@
446
472
 
447
473
  //親子関係
448
474
 
475
+ ```ここに言語を入力
476
+
449
477
  add_action('admin_menu', function() {
450
478
 
451
479
  remove_meta_box('pageparentdiv', 'member', 'normal');
@@ -478,6 +506,8 @@
478
506
 
479
507
  }
480
508
 
509
+ ```
510
+
481
511
 
482
512
 
483
513
  親子関係を持たせたいのでpage-〇〇.phpでも試してみましたが、タクソノミーを使って親子関係ができるならarchiveとsingleで作成したいです。