简体   繁体   中英

How To Get ACF Field in Custom Post Type Loop

I created a custom post type for 'projects'. I also created custom field for the post type 'projects', however i cant seem to access them, not sure what im doing wrong. Here's my code:

<?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)',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM