高级客户领域和自定义帖子类型ui wordpress

时间:2018-06-06 04:37:23

标签: php wordpress custom-post-type advanced-custom-fields

我有一个问题 请有人告诉我这段代码中的问题在哪里

    <?php $loop = new WP_Query(array( 'post_type' => 'about_us', 'orderby' => 'post_id', 'order' => 'ASC' )); ?>
    <?php while($loop -> have_post()) : $loop -> the_post(); ?>
        <div class="col-lg-4 col-sm-6 col-xs-12">
            <i class="<?php the_field('about_us_icon'); ?>" aria-hidden="true"></i>
            <div class="textA">
                <h3><?php the_field('about_us_title'); ?></h3>
                <p><?php the_field('about_us_text'); ?></p>
            </div>
        </div>
    <?php endwhile; wp_reset_query(); ?>    

谢谢!!

2 个答案:

答案 0 :(得分:0)

尝试使用以下代码

<h3><?php echo get_post_meta(get_the_ID(), 'about_us_title',true); ?></h3>
<p><?php echo  get_post_meta(get_the_ID(), 'about_us_text',true); ?></p>

假设您在每个帖子的postmeta中都有元键

答案 1 :(得分:0)

谢谢大家 我发现了这个问题 它在每页的帖子中

$args = array( 'post_type' => 'about_us', 'posts_per_page' => 6 );
$loop = new WP_Query( $args );

我忘了添加posts_per_page 谢谢大家的时间

相关问题