Title: アドバンスカスタムフィールドの繰り返しフィールドについて
Last modified: 2016年7月30日

---

# アドバンスカスタムフィールドの繰り返しフィールドについて

 *  [melloncollie](https://ja.wordpress.org/support/users/melloncollie/)
 * (@melloncollie)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/)
 * こんばんは。
    アドバンスカスタムフィールドの繰り返しフィールドを使用しているの
   ですが、複数あるサブフィールドの中で特定のサブフィールドが未入力の場合は表示しない
   ようにしたいのですが、出来ずにつまづいています。
 * <div id=”tab-1″>
    <?php if(get_field(‘fields_group’)): ?> <?php while(has_sub_field(‘
   fields_group’)): ?> <table id=”group”> <tbody> <tr> <th>サブフィールド①</th> 
   <td><?php the_sub_field(’sub_field01′); ?></td> </tr> <tr> <th>サブフィールド
   ②</th> <td><?php the_sub_field(‘sub_field02’); ?></td> </tr> <tr> <th>サブフィールド
   ③</th> <td><?php the_sub_field(‘sub_field03’); ?></td> </tr> </tbody> </table
   > <? endwhile; ?> </div> <?php endif; ?>
 * 例えば上の様な構成でサブフィールド②の<?php the_sub_field(‘sub_field02’); ?>の
   部分が未入力の場合はサブフィールド②の<tr></tr>の部分ごと非表示にしたいと思って
   います。
 * どなたかご教授いただけると幸いです。
 * よろしくお願いいたします。

4件の返信を表示中 - 1 - 4件目 (全4件中)

 *  [Daisuke Takahashi](https://ja.wordpress.org/support/users/extendwings/)
 * (@extendwings)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/#post-199368)
 * [has_sub_field()関数](http://www.advancedcustomfields.com/resources/has_sub_field/)
   は使えませんか？
 *  トピック投稿者 [melloncollie](https://ja.wordpress.org/support/users/melloncollie/)
 * (@melloncollie)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/#post-199369)
 * Daisuke Takahashiさま
 * ありがとうございます。
 * has_sub_field()関数ですね。
 * トライしてみます！
 *  トピック投稿者 [melloncollie](https://ja.wordpress.org/support/users/melloncollie/)
 * (@melloncollie)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/#post-199373)
 * すいません。
 * 下の様なコードにしたら、未入力の場合は表示されなくなりましたが、今度は入力して
   も表示されないようになってしまいました。
 * <div id=”tab-1″>
    <?php if(get_field(‘fields_group’)): ?> <?php while(has_sub_field(‘
   fields_group’)): ?> <table id=“fields_group”> <tbody> <tr> <th>サブフィールド
   ①</th> <td><?php the_sub_field(’sub_field01′); ?></td> </tr> <?php if( get_sub_field(‘
   fields_group’) ): ?> <?php while(has_sub_field(‘fields_group’)): ?> <tr> <th>
   サブフィールド②</th> <td><?php $variable = get_sub_field(‘sub_field02’); ?></
   td> </tr> <? endwhile; ?> <?php endif; ?> <tr> <th>サブフィールド③</th> <td><?
   php the_sub_field(‘sub_field03’); ?></td> </tr> </tbody> </table> <? endwhile;?
   > </div> <?php endif; ?>
 * 書き方が間違っているのでしょうか？
 * よろしくお願いいたします。
 *  トピック投稿者 [melloncollie](https://ja.wordpress.org/support/users/melloncollie/)
 * (@melloncollie)
 * [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/#post-199381)
 * すいません。
    下のコードで自己解決しました。
 * <div id=”tab-1″>
    <?php if(get_field(‘fields_group’)): ?> <?php while(has_sub_field(‘
   fields_group’)): ?> <table id=“fields_group”> <tbody> <tr> <th>サブフィールド
   ①</th> <td><?php the_sub_field(’sub_field01′); ?></td> </tr> <?php if( get_sub_field(‘
   sub_field02’)): ?> <tr> <th>サブフィールド②</th> <td><?php the_sub_field(‘sub_field02’);?
   ></td> </tr> <?php endif; ?> <tr> <th>サブフィールド③</th> <td><?php the_sub_field(‘
   sub_field03’); ?></td> </tr> </tbody> </table> <? endwhile; ?> </div> <?php endif;?
   >
 * Daisuke Takahashiさま
    ありがとうございました。

4件の返信を表示中 - 1 - 4件目 (全4件中)

 トピック「アドバンスカスタムフィールドの繰り返しフィールドについて」には新たに返信
することはできません。

## タグ

 * [AdvancedcustomFields](https://ja.wordpress.org/support/topic-tag/advancedcustomfields/)
 * [アドバンスカスタムフィールド](https://ja.wordpress.org/support/topic-tag/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/)
 * [サブフィールド](https://ja.wordpress.org/support/topic-tag/%e3%82%b5%e3%83%96%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/)

 * フォーラム: [プラグイン](https://ja.wordpress.org/support/forum/plugins/)
 * 4件の返信
 * 2人の参加者
 * 最後の返信者: [melloncollie](https://ja.wordpress.org/support/users/melloncollie/)
 * 最後の活動: [11年、 4ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%a2%e3%83%89%e3%83%90%e3%83%b3%e3%82%b9%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%95%e3%82%a3%e3%83%bc/#post-199381)
 * 状態: 未解決

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
