I am trying to get results from a relatedTo query, but only if there are more than say 1 results. Right now I am using two queries to achieve this, like so:
{% set authors = craft.entries({
section: 'authors',
with: [
'authorImage',
],
limit: 18,
order: 'authorSurname asc'
}) %}
{% for author in authors %}
{% set relatedEntries = craft.entries.section('articles').sponsoredAuthor('= 0').relatedTo(author) %}
{% if relatedEntries|length > 1 %} ... {% endif %}
{% endfor %}
But this messes up pagination (amongst other things) because the loop will iterate no mater if the related entries have more than 1 result. So I was wondering if it is possible (without using a custom query) to have the same result as a single query, so that the results match the number of the items in the loop and pagination does not break. Something like:
authors = craft.entries.section('authors').relatedTo('articles where articles results > 1)
or something like that. Is it possible?
Thanks!
relatedTo({ sourceElement: craft.entries.section('articles').sponsoredAuthor('= 1'), field: 'relatedAuthor'
but still not sure how to get the length / results from Articles