Get Terms from Custom Taxonomy and Current Post

You can post the terms by using wp_get_object_terms

$terms = wp_get_object_terms($post->ID, 'departments');
if(!empty($terms)){
  foreach($terms as $term){
    $exampleName = $term->name;
    $exampleSlugs[] = $term->slug;
  }
}

Alternatively you can try to first ensure that the right taxonomy is being used:

$taxonomies = get_taxonomies();

echo '<pre>';
print_r($taxonomies);
echo '</pre>';

If everything is allright you’ll see an array with all the taxonomies, and the taxonomy “departments” is present in this array.

When you want to output all the terms you can then use this:

echo '<pre>';
$departments = get_terms( 'departments', 'orderby=count&hide_empty=0' );
print_r($departments);
echo '</pre>';

Then you can use it anyway you want.

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