Exists
Use the If
tag with loop exists
to check if a loop has any items.
It is followed by a list of attributes for the Loop tag.
<If loop exists type=post name=example>
Inside the condition, use the Loop tag without attributes to loop through the result.
<If loop exists type=post name=example>
<Loop>
<Field title />
...
</Loop>
</If>
For example, this lets you wrap the loop with a container element only when it has items.
Else
Use the Else
tag for when the loop has no result.
<If loop exists type=post name=example>
<Loop>
...
</Loop>
<Else />
Nothing found.
</If>
Not exists
Use the not
attribute to only check if nothing exists.
<If not loop exists type=post name=example>
Nothing found.
</If>
This may be useful if you don't need to loop through the results.