<?php $active_category = $args["active_category"];
$anchor = $args["filter_anchor"] ?? false;
if (isset($args["categories"]) && !empty($args["categories"])): ?>
  <div class="category-filter-row row">
    <?php foreach ($args["categories"] as $category):

      $thumbs =
        rwmb_meta(
          "category_thumbnail",
          [
            "object_type" => "term",
            "size" => "thumbnail",
          ],
          $category->term_id ?? "",
        ) ?? [];
      $thumb = reset($thumbs);
      ?>
      <div class="col-6 col-sm-12">
        <a 
          href="<?= get_category_link($category) . ($anchor ? "#$anchor" : "") ?>" 
          class="category<?= $active_category instanceof WP_Term && $active_category->term_id == $category->term_id ? " active" : "" ?>">
          <?php if (isset($thumb["full_url"]) && !empty($thumb["full_url"])): ?>
            <img class="image" src="<?= $thumb["full_url"] ?>" alt="<?= $category->name ?: "" ?>">
          <?php endif; ?>
           <span class="name"> 
            <?= $category->name ?>
           </span>
        </a>
      </div>
    <?php
    endforeach; ?>
  </div>
<?php endif; ?>
