hoping to get a bit of direction here.
I have an ACF Field Group assigned to show on a Insights CPT.
Obviously the location rules control which editor it shows in, in this case it shows If post type is equal to Insights and Post Template is equal to Video.
This works well when adding my custom code to insights_video.php
$playtime = $content['play_time'];
<p class="dashicons-before dashicons-clock"> <?= $playtime ?> mins</p>
Very simple and works well !
My problem is when i try to add the code to the Insights Archive page within the loop, nothing happens
<?php if ($insights->have_posts()) :
while ($insights->have_posts()) : $insights->the_post();
$topics = get_the_terms($post->ID, 'topic');
$images = get_field('images');
$playtime = $content['play_time'];
$content = get_field('content'); ?>
<div class="tst-content-tile">
<a href="<?= get_permalink() ?>" class="tst-content-tile__image">
<div class="tst-content-tile__image-inside" style="background-image: url(<?= $images['preview_image']['sizes']['large'] ?>)"></div>
<div class="tst-content-tile__image-overlay">
<div class="tst-content-tile__image-overlay-blue"></div>
<img src="<?= get_stylesheet_directory_uri() ?>/assets/images/content-tile-link-arrow.svg" class="tst-content-tile__image-overlay-arrow">
</div>
</a>
<div class="tst-content-tile__tags-container">
<?php if($topics): ?>
<?php foreach($topics as $topic): ?>
<div class="tst-content-tile__tag"><?= $topic->name ?></div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<h5><?= get_the_title() ?></h5><p class="dashicons-before dashicons-clock"> <?= $playtime ?> mins</p>
<p><?= $content['summary'] ?></p>
<a href="<?= get_permalink() ?>" class="tst-button">Read more</a>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
Any direction would be great .. many thanks
I'll write a complete answer as comment is pretty limited :/
There is an error in your code.
This can't work:
...
$playtime = $content['play_time'];
$content = get_field('content');
...
Because you ask PHP to affect the value of key 'play_time' from the array $content BEFORE you affect any value to $content.
You should invert those two lines :
...
$content = get_field('content');
$playtime = $content['play_time'];
...
THis way PHP know the value affected to the variable $content.