I would like to set up a query to find the latest news article that has a video attached to it ('video' is a matrix field with a block type that is also called 'video' and a field called 'videoUrl').

I know I can use the following query, but I get stuck defining searchQuery. Or is there another method?

{% set results = craft.entries() .search(searchQuery) .one() %}


1 Answer 1

No need to use search in this case.

{% set results = craft.entries.videoField(':notempty:').orderBy('postDate desc').one() %}
  • Thanks, it works!
    – Matthias
    Commented Sep 28, 2020 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.