-
Hello Basti, once again thanks for providing this great theme. My question is: how can i customize my post category badges? Let's suppose i have some "travels" and "guides" options, can i do it via Scss? I have searched around, and tryed some, but none worked, since there is no "id" or post class generation. Thanks once again, im sure its my lack of php knowledge. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, thank you! The category badge is a pluggable function in https://github.com/bootscore/bootscore/blob/main/inc/template-tags.php. You can simply override this in your child's functions.php. Note that function bootscore_category_badge() {
if ('post' === get_post_type()) {
echo '<div class="category-badge mb-2">';
$thelist = '';
$i = 0;
foreach (get_the_category() as $category) {
if (0 < $i) $thelist .= ' ';
$thelist .= '<a href="' . esc_url(get_category_link($category->term_id)) . '" class="badge text-bg-secondary text-decoration-none">' . $category->name . '</a>';
$i++;
}
echo $thelist;
echo '</div>';
}
} But I think you want to style them individually for each category, right? So, let's search for the badge which contains a category name and change // Category badge colors
$('.badge:contains("Travels")').closest('.badge').removeClass('text-bg-secondary').addClass('text-bg-success');
$('.badge:contains("Guides")').closest('.badge').removeClass('text-bg-secondary').addClass('text-bg-danger'); Solved? |
Beta Was this translation helpful? Give feedback.
Hi,
thank you! The category badge is a pluggable function in https://github.com/bootscore/bootscore/blob/main/inc/template-tags.php. You can simply override this in your child's functions.php. Note that
text-bg-{color}
classes are new in Bootstrap 5.2.0. If you are using an earlier version, you must usebg-{color}
instead.