前提・実現したいこと
ACF Pro で設定したリーピーターフィールドが出力されません。
自分ではどこにミスがあるのか発見できず行き詰っています。
出力先(記述先)は、固定ページです。固定ページにInsert PHP Code Snippetプラグインを使ってショートコード化させて表示を試みていますが、出力してくれません。どなたか教えていただけないでしょうか。
現在出力しているソースコード
<table class="table02"><tbody></tbody></table>
該当のソースコード
<table class="table02"> <tbody> <?php if(have_rows('options_list')) : while(have_rows('options_list')): the_row(); ?> <tr> <th> <?php the_sub_field('options_list_name'); ?> </th> <td> <?php the_sub_field('options_list_price'); ?> </td> </tr> <?php endwhile; ?> </tbody> </table> <?php endif; ?>
現在のACF側の設定スクショ
functions.phpに管理画面左メニュー
function create_post_type() { //料金システムページオプション $Supportcustom = [// 投稿画面で表示される項目の設定 'title', // 記事タイトル ]; register_post_type( 'myoptions', // URLになる部分 array( 'label' => 'オプションリスト', // 管理画面の左メニューに表示されるテキスト 'labels' => array( 'all_items' => 'オプション一覧'// 管理画面の左メニューの下層に表示されるテキスト ), 'public' => true, 'has_archive' => true, 'menu_position' => 9, 'supports' => $Supportscustom ) ); } add_action( 'init', 'create_post_type' );
###追記
archive-myoptions.phpで出力される一覧アーカイブページでは無事に出力されています。
###追記
<?php $args = array( 'post_type' => 'myoptions' ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <?php if(have_rows('options_list')) : ?> <table class="table02"> <tbody> <?php while(have_rows('options_list')): the_row(); ?> <tr> <th> <?php the_sub_field('options_list_name'); ?> </th> <td> <?php the_sub_field('options_list_price'); ?> </td> </tr> <?php endwhile; ?> </tbody> </table> <?php endif; ?> <?php endforeach;?>
回答2件
あなたの回答
tips
プレビュー