Reputation: 1
I've almost found a good workaround for Blogger's lack of a categories field. I use the "contains" operator to filter all labels that contain "Category" into a Categories list and "not contains" to put the remaining labels into a Tags list.
My code within the post loop looks like this:
Categories:
<b:loop values='data:post.labels where (l => l.name contains "Category")' var='label'>
<a expr:href='data:label.url' rel='tag'><data:label.name/></a>,
</b:loop>
Tags:
<b:loop values='data:post.labels where (l => l.name not contains "Category")' var='label'>
<a expr:href='data:label.url' rel='tag'><data:label.name/></a>,
</b:loop>
So, a post with labels "Category Art, Zebra, Category Tea, Category Junk, Banana, Arrow," will output "Categories: Category Art, Category Junk, Category Tea, Tags: Arrow, Banana, Zebra,"
I would like it to look a bit cleaner by removing or hiding the "Category" part from the label name after the labels have been sorted. Is there any way of doing this within Blogger's backend or do I have to use JavaScript?
Upvotes: 0
Views: 79
Reputation:
You can do this using only JavaScript
document.querySelectorAll('a[rel=tag]').forEach((e) => {
e.innerText = e.innerText.replace('Category','');
});
Upvotes: 1