我试图在for each循环中回显分类法名称,而不是此行的类别slug:
<div class="title"><?php echo $taxonomy; ?></div>
 我试过:
<div class="title"><?php echo $taxonomy->name; ?></div>
 但我得到一个错误:“quot;正在尝试获取非对象的属性“name”;
这是我的代码:
<?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; ?>
 我错过什么了吗?