Hello, trying to list out 4 CPT post objects to my ‘category-distributions.php’ archive page. I am using the first of the two options on the “Display data for multiple post objects” section at “Post Object” page.
I would like to show the post thumbnail and the excerpt/content. I’ve put most of it together, and I feel really close because one of the posts will show, but only one. Here is my code:
<?php if (is_category('distributions')) :?>
$post_objects = get_field('distribution_post_01');
// echo '<pre>';
// echo '</pre>';
<?php foreach ($post_objects as $post): // variable must be called $post (IMPORTANT)?>
<div class="cell medium-3">
<a href="<?php the_permalink(); ?>">
<!-- Hook up Interchange as an img src -->
<div class="callout callout-hover-reveal" data-callout-hover-reveal>
<img class="cell medium-6 category-feat" data-interchange="[<?php the_post_thumbnail_url('fp-small'); ?>, small], [<?php the_post_thumbnail_url('fp-medium'); ?>, medium], [<?php the_post_thumbnail_url('fp-large'); ?>, large], [<?php the_post_thumbnail_url('fp-xlarge'); ?>, xlarge]">
<noscript><img src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo $alt_text; ?>" /></noscript>
<p><?php the_field('synopsis'); ?></p>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly?>
<?php endif; ?>
<?php endif;?> <!-- END category is distributions -->
I feel like I’m really close! Thank you for your help!
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users