I have two Custom Post Types – one is “Banners” (the_banners) and the other one is “Content” (add_content). For the “Content” CPT I created a taxonomy called “Home Banners” (add_home_banner). For every new content, I always checkmark the “Full Banner” category from the Home Banners’ taxonomy.
When I click on the CPT “Banners” I have a relationship field (banner_selection) that pulls all the “Full Banners” category that I marked when adding the content.
My main question is: I would like to select several items in the relationship field. However, I’d like only to display one post per page and randomize it when refreshing the page. I’ve made the following code!
$ids = get_field('banner_selection', false, false);
'post_type' => 'the_banners',
'posts_per_page' => 1,
'post__in' => $ids,
'post_status' => 'any',
'orderby' => 'rand',
$fullbanner = new WP_Query ( $args );
<?php if ( have_posts() ) : while ( $fullbanner->have_posts() ) : $fullbanner->the_post(); ?>
$banners = get_field('banner_selection');
<?php if( $banners ): ?>
<?php foreach( $banners as $banner ): ?>