I'm trying to echo the taxonomy name inside a for each loop, instead of the category slug at this line :
<div class="title"><?php echo $taxonomy; ?></div>
I tried :
<div class="title"><?php echo $taxonomy->name; ?></div>
but I get an error : " Trying to get property 'name' of non-object"
Here is my code :
<?php
$custom_post_type = get_queried_object();
$custom_post_type_name = $custom_post_type->name;
$taxonomies = get_object_taxonomies($custom_post_type_name);
?>
<?php foreach ($taxonomies as $taxonomy) : ?>
<?php $categories = get_terms(array(
'orderby' => 'name',
'taxonomy' => $taxonomy,
'order' => 'ASC',
'hide_empty' => 1,
)); ?>
<div id="filters-<?php echo $taxonomy; ?>" class="filter-group">
<div class="title"><?php echo $taxonomy; ?></div>
<ul class="filters-select" data-filter-group>
<?php foreach ($categories as $category) : ?>
<li>
<label><?php echo $category->name; ?></label>
<input type="checkbox" value=".<?php echo $category->slug; ?>" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
Am I missing something?