Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在自定义Post类型循环中获取ACF字段_Php_Wordpress_Loops_Advanced Custom Fields - Fatal编程技术网

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现场组的屏幕截图,以及可以看到现场和数据的项目帖子吗。