我有一页,就这么说吧page-home.php
我还有一个页面叫做page-custom-field.php
我想在第一页的某个部分循环page-custom-field.php
页面并在其自身上显示。这是我迄今为止尝试的代码。我在第二页使用高级自定义字段。
我的If语句
主页。php
<?php
$args = array(
\'post_type\' => array(
\'features\'
),
\'posts_per_page\' => 1,
);
$query = new WP_Query( $args );
?>
<div id="homeSpecials" class="section__content small-12 small-centered medium-10 columns">
<?php if($query -> have_posts()) : while( $query->have_posts() ) : $query->the_post(); ?>
<?php include \'page-custom-field.php\' ?>
<?php endwhile; endif;//ends\'menu_flexible\'?>
页面自定义字段。php
<?php if( have_rows(\'menu_item\') ): ?>
<?php while( have_rows(\'menu_item\') ): the_row(); ?>
<!-- loop through the rows of data || DONT CLOSE THE LOOP IN AN \'IF\' STATEMENT -->
<?php if( get_row_layout() == \'simple_menu_item\' ): ?>
<article class="menu-item small-12 medium-6 columns">
<h3><?php the_sub_field(\'item_name\') ?><span class="menu-item__price"><?php the_sub_field(\'item_price\') ?></span></h3>
<p>
<?php the_sub_field(\'item_description\') ?>
</p>
</article>
<!-- elseif is the last loop -->
<?php elseif( get_row_layout() == \'line_item_with_modifiers\' ): ?>
<article class="menu-item small-12 columns">
<h3><?php the_sub_field(\'item_name\') ?><span class="menu-item__price"><?php the_sub_field(\'item_price\') ?></span></h3>
<p>
<?php the_sub_field(\'item_description\') ?>
</p>
<?php if( have_rows(\'item_modifiers\') ): ?>
<?php while( have_rows(\'item_modifiers\') ): the_row(); ?>
<div class="small-12 medium-3 columns">
<h4><?php the_sub_field(\'modifier_title\') ?></h4>
<ul>
<?php if( have_rows(\'modifier_column\') ): ?>
<?php while( have_rows(\'modifier_column\') ): the_row(); ?>
<li><?php the_sub_field(\'modifier_name\') ?></li>
<?php endwhile;?>
<?php endif;?>
</ul>
</div>
<?php endwhile;?>
<?php endif;?>
</article>
<!-- final \'endif\' closes the flexible content loop -->
<?php endif; ?>
<?php endwhile; endif;//ends\'menu_flexible\'?>