Query Custom posts of same taxonomy as the post itself

Assuming you want it for all the terms in the ‘Genre’ taxonomy. In the loop on the single Service post page, put this code:

<?php
$the_terms = get_the_terms( get_the_ID, 'genre' );
if(isset($the_terms) && !empty($the_terms)){
    foreach($the_terms as $the_term){
        $the_terms_slugs[] = $the_term->slug;
    }
}

$works = get_posts(array(
                                'post_type' => 'works',
                                'posts_per_page' => 5,
                                'tax_query' => array(array(
                                    'taxonomy' => 'genre',
                                    'field' => 'slug',
                        'terms' => $the_terms_slugs
                                )));

//This will print the works which have the same genre as the current post
print_r($works_query);
?>

If you want it only for ‘novice’, let me know and I’ll modify the code.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)