<!-- begin custom related loop, isa --><?php // get the custom post type's taxonomy terms$custom_taxterms = wp_get_object_terms( $post->ID, 'project_category', array('fields' => 'ids') );// arguments$args = array('post_type' => 'project','post_status' => 'publish','posts_per_page' => 3, // you may edit this number'orderby' => 'rand','tax_query' => array( array( 'taxonomy' => 'project_category', 'field' => 'id', 'terms' => $custom_taxterms )),'post__not_in' => array ($post->ID),);$related_items = new WP_Query( $args );// loop over queryif ($related_items->have_posts()) :echo '<ul>';while ( $related_items->have_posts() ) : $related_items->the_post();?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li><?phpendwhile;echo '</ul>';endif;// Reset Post Datawp_reset_postdata();?><!-- end custom related loop, isa -->Link: https://isabelcastillo.com/related-custom-post-type-taxonomy
