I’m trying to create a new category filter for a client’s website. But I can not load the taxonomy terms on the page.
This is the filter I’m trying to create on the page.
The name of the category is categoria_sistemas_sanitarios
<ul id="filters" class="clearfix">
<?php
$terms = get_the_terms( $post->ID , 'categoria_sistemas_sanitarios' );
$count = count($terms);
echo "<script>console.log( 'Debug Objects: " . $terms . "' );</script>";
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<li><span class="filter active" data-filter="';
$li = ' ';
foreach ( $terms as $term) {
$li .= '.' . $term->slug.', ';
}
$li = rtrim($li, ', ');
echo $li;
echo '">Todas as bombas</span></li>';
foreach ( $terms as $term ) {
echo '<li><span class="filter" data-filter=".' . $term->slug . '">' . $term->name . '</li>';
}
}
?>
</ul>
What I’m doing wrong?
Thanks for the help.