Home › Forums › Front-end Issues › Displaying a category ID › Reply To: Displaying a category ID
I think the problem might be I’m not sure where your code should be added in order for me to test the variables. I’ve probably complicated things by (ironically) trying to display a simplified code example. The full and complete code is below.
<?php $post_objects = get_field('right_1'); if( $post_objects ): ?>
<div class="promoWrapper">
<div class="promoBox clearfix">
<?php $post_objects = get_field('right_1'); if( $post_objects ): ?>
<?php foreach( $post_objects as $post_object): ?>
<h2>
<?php if(get_field('pb-link', $post_object->ID) != ""): ?> <!-- Gets the link for the promo box -->
<a href="<?php the_field('pb-link', $post_object->ID); ?>">
<?php endif; ?><!-- pb-link ENDS -->
<?php if(get_field('alternative_title', $post_object->ID) != ""): ?><!-- Gets the alternative title if there is one -->
<?php the_field('alternative_title', $post_object->ID); ?>
<?php else : ?>
<?php echo get_the_title($post_object->ID); ?>
<?php endif; ?><!-- alternative_title ENDS -->
<?php if(get_field('pb-link', $post_object->ID) != ""): ?></a><?php endif; ?>
</h2>
<?php if(get_field('pb-image', $post_object->ID) != ""): ?>
<a href="<?php the_field('pb-link', $post_object->ID); ?>">
<img src="<?php the_field('pb-image', $post_object->ID); $size = "promo-box" ?>" class="promoImage" alt="<?php echo get_the_title($post_object->ID); ?>" title="<?php echo get_the_title($post_object->ID); ?>" />
</a>
<?php endif; ?><!-- pb-image ENDS -->
<div><?php the_field('pb-content', $post_object->ID); ?></div>
<?php if(get_field('pb-link', $post_object->ID) != ""): ?><span><a class="moreLink" href="<?php the_field('pb-link', $post_object->ID); ?>">More...</a></span><?php endif; ?>
<!-- If the promo box is showing latest news or reports -->
<?php if(get_field('latest_news_or_reports', $post_object->ID) == "news"): ?>
<?php query_posts( array ('posts_per_page' => 5, 'order'=> 'DESC', 'orderby' => 'date', 'category__in' => '' ) ); ?>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<li class="title"><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
<?php endif; ?><!-- News/Reports promoBox ENDS -->
<?php endforeach; ?>
<?php endif; ?>
</div><!-- .promoBox ENDS -->
</div><!-- .promoWrapper ENDS -->
<?php endif; ?><!-- right_1 ENDS -->
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!
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.