The way to use get_the_terms () is to pass it as a parameter the ID
of post
and the name of the taxonimía
, in your case sectores
.
foreach (get_the_terms(get_the_ID(), 'sectores') as $sector) {
print_r($sector);
}
This will return an object whose properties are the following, this is the content of the variable $sector
:
WP_Term Object
(
[term_id] => 'xxx'
[name] => 'xxx'
[slug] => 'xxx'
[term_group] => 'xxx'
[term_taxonomy_id] => 'xxx'
[taxonomy] => 'xxx'
[description] => 'xxx'
[parent] => 'xxx'
[count] => 'xxx'
[filter] => 'xxx'
)
If what you want is to assign an icon according to the name (I have not been very clear what you ask) you can do something like this:
echo ("<div class='iconos-sectores' style='display:flex;width:100%; margin-top:20px;'>");
foreach (get_the_terms(get_the_ID(), 'sectores') as $sector) {
if($sector->name === 'nombre_buscado'){
echo ("Icono Deseado");
}
}
echo ("</div>");