Count total results in loop
-
Hi Eliot,
It’s me agian, with another question.
I was trying to make a condition in an loop, that if the loop has just one result, the text “Announcement” will show before the first item, else “Announcements“.
I thought it could be done with
[if count=1]
, but I think that condition is only to check the number of the current item in the results, not the total results.Is there another way to check the total results of the loop?
The code below is what I’m using now (without counting).
[loop type=announcement field=expire after=now orderby=field_num order=ASC] [if first] <aside class="widget"> <h3 class="widgettitle">Announcements</h3> <div class="textwidget"> <ul> [/if] <li>[content]</li> [if last] </ul> </div> </aside> [/if] [if empty][/if] [/loop]
Thank you in advance!
Peter
https://www.ads-software.com/plugins/custom-content-shortcode/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Count total results in loop’ is closed to new replies.