1

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

1 Answer 1

2
No need to use search in this case.

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

Your Answer

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

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