如何在每个类别图片下方添加独特的文本?

哦,我明白了。 :slight_smile:

你仍然可以使用纯 SCSS 解决方案,方法是使用类别 slug:

:information_source: 如果你想在文本中添加换行符,请在文本中放入 \\A,并在 :after 伪元素属性中添加 white-space: pre;

$categories: "nature", "general";
$labels: "All natural!\A Naturaaal!" "Another text";

@each $category, $label in zip($categories, $labels) {
  body.category-#{$category} .category-heading .category-logo.aspect-image {
    max-height: none;
    &:after {
      display: block;
      content: $label;
      font-size: 1.25em;
      color: var(--primary-700);
      white-space: pre;
      text-align: center;
    }
  }
}

2 个赞