Say I have a Matrix that has the following fields:

  • Name
  • Age
  • Gender

How would I find Channel entries like:

  • the Channel entry's Age is between 20 and 25
  • the Channel entry's Age is between 20 and 25 and Gender is "Male"
  • the Channel entry has 1 Matrix entry only
  • the Channel entry has 2 Matrix entries
  • etc.

1 Answer 1


I take it you want this to be optimised and not use a whole bunch of conditions inside channel entries loops.

In that case, MySQL queries are your best bet here, IMHO. I would take the plugin route and create a plugin returning an array of entry_id and accepting the various parameters you need.

For example, you could create a plugin returning the entry_id of the entries having a matrix field with more than x entries. Such a plugin would be based on the following type of query:

SELECT DISTINCT `entry_id` FROM `exp_matrix_data` WHERE `field_id` = 48 GROUP BY `entry_id` HAVING COUNT(`entry_id`) > 2

You plugin tag would could easily pass it a parameter called nbr_matrix_rows with a value of x.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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