It’s done. Was missing one line of code.
Instead of this:
if ( ! empty( $post_terms ) ) {
foreach ( $post_terms as $post_term ) {
$term_slug = $term_slug . $post_term->slug . ' ';
}
}
I replaced by this code:
if ( ! empty( $post_terms ) ) {
foreach ( $post_terms as $post_term ) {
$term_slug = $term_slug . $post_term->slug . ' ';
$term_name = $post_term->name;
}
}
check if it’s ok.
-Rui