Normal behaviour of get_terms is not to return terms if there are no posts assigned to. But this is not the case, I can see terms assigned in admin and also checked the database and all seems fine. Also check this code:
$p = get_post(5018); // correctly returns the post
// works: returns the assigned term
$post_terms = wp_get_post_terms($p->ID, 'solutions_sectors', array("fields" => "all"));
// now the opposite:
$first = $post_terms[0];
$tid = $first->term_id;
// works: gives a list of post ids
$term_posts = get_objects_in_term($tid, 'solutions_sectors');
// still, this will output an empty array:
$terms = get_terms(array('taxonomy' => 'solutions_sectors');
// while this will output the right array (obviously):
$terms = get_terms(array('taxonomy' => 'solutions_sectors', 'hide_empty' => false));
So, my posts do have the terms, but get_terms seems not to realise it. Why?
Please note the following:
I'm using custom post types with custom taxonomies
I'm using polylang as the languages plugin (but all the posts and terms seems to be correctly translated and assigned)