LoginSignup
0
0

More than 1 year has passed since last update.

WordPressのACFを使ってよくあるご質問のコード

Posted at

ここ数ヶ月で、WordPressのACFを使ってよくあるご質問のコードを3回くらい書いているような気がします。
だいたいのhtmlは変わらないので、使い回せるように貼っておきます。

<?php if( have_rows('faq_list') ): ?>
    <ul class="faq_ul">
    <?php while ( have_rows('faq_list') ) : the_row(); ?>
        <li class="faq_li">
            <div class="q_area">
                <span class="q_icon">Q</span>
                <p class="q_text"><?php the_sub_field('question'); ?></p>
            </div>
            <div class="a_area">
                <span class="a_icon">A</span>
                <p class="a_text"><?php the_sub_field('answer'); ?></p>
            </div>
        </li>
    <?php endwhile; ?>
    </ul>
<?php endif; ?>

ACFの繰り返しフィールドを使っています。
有料プラグインです。

ページによっては、FAQのGoogle構造化データを入れるといいかもです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0