我有以下代码,带来了3个职位或项目职位;
但我希望它只显示当前帖子类别中的帖子;
<?php get_header(); ?>
<article class="post">
<div class="wrapper">
<?php
while ( have_posts() ) : the_post();
get_template_part( \'content-portfolio\' );
rainy_projectbottom_nav();
endwhile;
?>
</div>
</article>
<div class="wrapper">
<header class="header">
<h2 class="subtitle">Check out more projects</h2>
</header>
<div class="grid"><?php
while ( have_posts() ) : the_post();
endwhile;
$cats = get_post_meta( $post->ID, \'rainy_multicheck\', false );
$terms_args = array(
\'exclude\' => $cats
);
$terms = get_terms( \'project-category\', $terms_args );
$query_args = array(
\'post_type\' => \'project\',
\'project-category\' => \'Print\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'project-category\',
\'field\' => \'id\',
\'terms\' => $cats,
\'post__not_in\' => array($post->ID),
\'operator\' => \'NOT IN\'
)
),
\'posts_per_page\' => 3
);
$portfolio_query = new WP_Query( $query_args );
if ( $portfolio_query->have_posts() ) :
while ( $portfolio_query->have_posts() ) : $portfolio_query->the_post();
get_template_part( \'content-related\' );
endwhile;
wp_reset_postdata();
else :
get_template_part( \'content-none\' );
endif;
?></div> </div></main> <?php get_footer(); ?>