Home › Forums › Front-end Issues › Custom field on post not accessible on archive page? › Reply To: Custom field on post not accessible on archive page?
Ok, I don’t know why, but it’s working as expected now.
It must have been a cache issue, but I swear I was clearing the cache regularly.
For the sake of closure, here’s the code that worked (once the field was accessible):
<section class="center-align stories" id="stories">
<div class="wrap cf">
<div class="row">
<?php
if (have_posts()) : while (have_posts()) : the_post();
$my_id = get_the_ID();
?>
<?php // Only show posts where 'visibile_on_index' is not 0 (either 1 or unset)
if (get_post_field('visible_on_index', $my_id) != 0) { ?>
<div class="fourth <?php foreach(get_the_category() as $cat){ echo ' '.$cat->slug; }?>">
<div class="inner">
<a href="<?php the_permalink(); ?>" class="img-holder" style="background-image: url(<?php the_post_thumbnail_url('full'); ?>)"></a>
<a href="<?php the_permalink(); ?>">
<h4><?php the_title(); ?></h4>
</a>
<?php the_excerpt(); ?>
</div>
</div>
<?php }; ?>
<?php endwhile; ?>
<?php bones_page_navi(); ?>
<?php endif; ?>
</div>
</div>
</section>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.