You can use wp_get_post_terms()
to pull the terms.
$taxonomy = 'project-category';
$terms = wp_get_post_terms( $post->ID, $taxonomy);
var_dump($terms);
wp_get_post_terms()
will return an array of terms because multiple terms may be assigned to a single post. This means that you will potentially get a set of terms, not just one, so you will need to choose which to use. That is, the first terms? The last term? The first would be $terms[0]->slug
for example. This would be the case for your “pattern” here:
'post_type' => 'project',
'project-category' => 'Print',
You can alternately use a tax_query
as found in the Codex:
array(
'taxonomy' => 'project-category',
'field' => 'term_id',
'terms' => array( 103, 115, 206 ),
),
Which in your case would look like:
$taxonomy = 'project-category';
$terms = wp_get_post_terms( $post->ID, $taxonomy,array("fields" => "ids"));
$query_args = array(
'post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'project-category',
'field' => 'term_id',
'terms' => $terms,
)
),
'posts_per_page' => 2
);