Below I have this code in single-courses.php which is currently displaying all the the courses. The goal is to show only related courses based on that courses' taxonomy term (category). Help please.
<?php
$related = get_posts( array(
'taxonomy' => 'course_category',
'post_type' => 'courses',
'numberposts' => -1
)
);
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<div class="row next-chapter-list" onclick="location.href='<?php the_permalink();?>';">
<div class="col-md-10 col-9 valign text-left">
<?php the_title(); ?>
</div>
<div class="col-md-2 col-3 valign text-right">
<i class="bi bi-play-fill"></i>
</div>
</div>
<?php }
wp_reset_postdata(); ?>
Comments
i found a solution literally after i posted this question, sorry- but this is what worked for me.
Add Comment