Related posts WordPress

I’m looking for a solution to show related posts from a different CPT.
There are two CPT’s (Projects and Products) both have multiple sub categories (don’t know if that ok…).

When on a: Single Post > Projects CPT > SportsCars
in the footer it must show the latest two posts of: Products CPT > Sportscars

Read More

The code i have now just filters on the CPT, not the SubCategrories. This is the code of single_products.php:

    <section class="content">
        <div class="container">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <h1><?php the_title(); ?></h1>
                <?php the_content(); ?>
            <?php endwhile; endif; ?>
        </div>
    </section>

    <div class="container">
        <div class="divider-small"></div>
    </div>

    <section class="news">

        <div class="container">
            <h2>Related projects</h2>
            <div class="row">

                <?php 
                $wp_query = new WP_Query(array('post_type' => 'projects', 'post__not_in' => array( $post->ID ), 'showposts' => 2)); 
                $i = 0;
                if ( $wp_query->have_posts() ): while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>


                <div class="col-md-6 item">

                    <div class="<?php if($i++ == 1): echo 'green'; else: echo 'blue'; endif; ?> clearfix">

                        <div class="col-sm-6">

                            <div class="text">                              
                                <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                                <p><?php echo excerpt(20); ?></p>
                            </div>  <!-- end text -->

                            <div class="meer-news">
                                <a href="<?php the_permalink(); ?>" class="readmore" title="<?php the_title(); ?>">Lees meer ></a>
                            </div> <!-- end meer-news -->

                        </div>   <!-- end col-sm-6 -->

                        <div class="col-sm-6">
                            <div class="image">
                                <?php
                                if ( has_post_thumbnail() ) :
                                        the_post_thumbnail( 'news_latest' );
                                    else: 
                                        // backup
                                    endif;
                                ?>
                            </div> <!-- end image -->
                        </div> <!-- end col-sm-6 -->

                    </div>

                </div> <!-- end item -->
                <?php endwhile; endif; wp_reset_query(); ?>

            </div> <!-- end row -->
        </div> <!-- end container -->

    </section>

Related posts