this question already asked many times but I am unable to find a solution for my problem. My php knowledge is very limited.
I am building a wordpress website where there a custom taxonomy called "series". This website will have many series and I am using a custom field for grouping series. So it will be easy to organize series on frontend in groups.
So here the code for showing 'series' (https://pastiebin.com/5b445ae944a13):
<?php $x = 0; foreach ( $new_mod_series as $cat ): ?>
<?php $seriestype = get_field( "series_type", $cat ); ?>
<?php while ( $seriestype == "interview" and $cat_post->have_posts() ): $cat_post->the_post(); ?>
Show interview series...
<?php endwhile; ?>
<?php if (++$x == 5) break; endforeach; ?>
This code <?php $seriestype = get_field( "series_type", $cat ); ?>
don't run outside of foreach loop and with this I can get value of 'series type' custom field. Then I am using $seriestype == "interview"
in while to show only series which are interview.
And now I am not getting expected or 5 foreach results because limiting only 'interview' series to show. But I need to show 5 recent interview series in a section, then other 5 series of another series section.
Is there anyway to solve my problem? With my limited php knowledge, I tried a lot but could not found any solution. Hopefully I was able to explain correctly.
Thanks Julash