I have a custom post type with custom category taxonomy. On the CPT single templae I want to list out other posts in same categories, but I can't get it to work.
My current code:
<?php
foreach ( Roots\Sage\Utils\get_the_category_bytax( get_the_ID(), 'project_category' ) as $cat )
$category_ids[] = $cat->term_id;
$projects = new WP_Query( array(
'post_status' => 'publish',
'post__in' => get_post_meta( get_the_ID(), 'carbonlimits_project_related', true ),
'post__not_in' => array( $current_post_id ),
'category__and' => $category_ids,
'post_type' => 'project',
'caller_get_posts' => 1,
'posts_per_page' => 4
) );
while ( $projects->have_posts() ): $projects->the_post() ?>
<div id="project-<?php the_ID() ?>" <?php post_class( 'col-sm-3' ) ?>>
<a href="<?php the_permalink() ?>">
<?php
$thumbnail = get_the_post_thumbnail( get_the_ID(), 'project-listing' );
if ( $thumbnail )
echo $thumbnail;
else
echo '<img src="/wp-content/themes/carbonlimits/dist/images/blank.gif" width="380" height="380">';
?>
<h3><?= $projects->post->post_title ?></h3>
<span class="view-btn">View</span>
</a>
</div>
<?php endwhile;
// var_dump( $projects->request );
wp_reset_postdata();
?>
Is it because it's a custom post type and taxonomy?