Php 如何在自定义Post类型循环中获取ACF字段
我为“项目”创建了自定义帖子类型。我还为帖子类型“项目”创建了自定义字段,但是我似乎无法访问它们,不确定我做错了什么。这是我的密码:Php 如何在自定义Post类型循环中获取ACF字段,php,wordpress,loops,advanced-custom-fields,Php,Wordpress,Loops,Advanced Custom Fields,我为“项目”创建了自定义帖子类型。我还为帖子类型“项目”创建了自定义字段,但是我似乎无法访问它们,不确定我做错了什么。这是我的密码: <?php $args = array ( 'post_type' => 'project', 'status' => 'publish', 'order' => 'ASC', 'posts_per_page' => -1 ); $the_query = new WP_Query($args); ?>
<?php
$args = array (
'post_type' => 'project',
'status' => 'publish',
'order' => 'ASC',
'posts_per_page' => -1
);
$the_query = new WP_Query($args);
?>
<div class="home-slider">
<?php if($the_query->have_posts()) : ?>
<?php while($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="slide">
<div class="project-name">
<p><?php the_title(); ?></p>
</div>
<div class="project-description">
<?php echo get_field('intro_text'); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
</div>
如果你的帖子类型被称为“项目”,这可能就是问题所在
'post_type' => 'project(s)',
您的代码似乎是正确的。你能分享你设置的acf现场组的屏幕截图,以及可以看到现场和数据的项目帖子吗。