I have a custom post type, that has several taxonomies.

For each one, I need to show something like:

Taxonomy name: Taxonomy value

So, since I have posts that have the following taxonomy tree:

Categories -> Bikes

Bikes Models -> Model 1

Bikes Brands -> Brand 1

Genre -> Male

I need to show all of them with the respective name and value.

I got all the post taxonomies, but I need to 'delete' part of it.

This is my code:

$args = array(
'post' => $post->ID,
'before' => '<p class="meta">',
'sep' => ' ',
'after' => '<p class="meta">',
'template' => '%s  %l<br/>',

That produces:

- Categorias | Acessório
- Tipos de Acessórios | Tipos de Acessórios 2
- Modelos de Acessórios | Modelos de Acessórios 3
- Marcas de Acessórios | Marca de Acessório 3
- Tamanhos | XL
- Gênero | Masculino
- Material Quadro | Carbono
- Extras |  Com garantia, Como novo, Dobrável, Dupla-Suspensão, Excelente estado, Exclui pedais, Exclui pneus, Exclui rodas, Pouco uso, Preço negociável, Sem selim e Tem amortecedor trás

The thing is:

  1. I need to exclude some of those taxonomys (Categorias, Tipos de acessórios, Modelos de Acessórios, Marcas de Acessórios & Extras)
  2. The ones I need to show, will ALWAYS BE DIFFERENT on each item. But the ones I need to exclude/hide WILL ALWAYS BE THE SAME.

1 Answer 1


Ok, I managed to do it with get_the_taxonomies()Codex and unset() PHP Manual

So, here is how the final code looks like:

//define the arguments so the output will have the format I want
$args = array(
    'template' => __( '%s: %l.' ), 
    'term_template' => '<a href="%1$s">%2$s</a>',
//get the array and store it
$taxList = get_the_taxonomies( $post->ID, $args );
//remove the categories I don't want based on their slug
//Show the list without the ones specified above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.