Rhys
April 24, 2024, 1:35pm
1
In the code below, I want to add suffix=" & Others"
only when there are more than two authors assigned to a post. How do I do that?
{{#if single_author}}
<span class="post-info__authors">{{authors limit="1" separator=", "}}</span>
{{else}}
<span class="post-info__authors">{{authors limit="2" separator=" and "}}</span>
{{/if}}
As it stands, the code above outputs:
One author if there is a single author assigned
Two authors with “and” separating them if two authors are assigned
Theme: Maali
fueko
April 24, 2024, 2:38pm
2
Hi @Rhys !
After customization, this code should work for you:
{{#has author="count:1"}}
{{authors}}
{{else has author="count:2"}}
{{authors separator=" and "}}
{{else has author="count:>2"}}
{{authors limit="2" separator=", "}} and others
{{/has}}
Rhys
April 25, 2024, 9:28am
3
Hi! Thanks for providing that. It works, but the CSS changes and I’m not sure where to tweak it to match the original.
Original: https://www.greatcentralgazette.org/
Using your code:
fueko
April 25, 2024, 9:44am
4
Based on your first example, it could look like this:
{{#has author="count:1"}}
<span class="post-info__authors">{{authors}}</span>
{{else has author="count:2"}}
<span class="post-info__authors">{{authors separator=" and "}}</span>
{{else has author="count:>2"}}
<span class="post-info__authors">{{authors limit="2" separator=", "}} and others</span>
{{/has}}