When I do a simple search on my site, I am searching across three channels. One of them is an image gallery set up using Matrix. In the Matrix field for that channel there is a column called "img_caption", which is, obviously, a caption for the image.

In my search results, I try to trap which channel a search result row is coming from and display the appropriate field (as the "excerpt") using conditionals, like this:

 {if summary!=""}{exp:ce_str:ing remove_html truncate="150"}{summary}{/exp:ce_str:ing}{/if}
 {if rick_summary!=""}{exp:ce_str:ing remove_html truncate="150"}{rick_summary}{/exp:ce_str:ing}{/if}
 {if img_caption!=""}{exp:ce_str:ing remove_html truncate="150"}{img_caption}{/exp:ce_str:ing}{/if}

I do have "custom_field" set to "yes" in the search results tag:

 {exp:search:search_results switch="resultRowOne|resultRowTwo" custom_fields="yes"}

This is working for {summary} and {rick_summary} but not for {img_caption}.

I've edited a few entries in the gallery and resaved them, thinking that might be the issue. And, the img_caption column as well as the matrix field is set to be searchable.

Search is finding results from the gallery, at least based on the entry title, so I am getting results, just nothing I can use as an excerpt.

Any ideas for me?

2 Answers 2


You can display custom field data, including Matrix fields, within the exp:search:search_results tag. In this case it just looks like you have the incorrect syntax.

Your img_caption field is a Matrix column. Matrix columns are only available within the Matrix tag pair, so the column name alone won't display anything.

So instead try:


Where matrix_custom_field_name matches the short name for your Matrix field.

As an aside.... Depending on how many rows are in your gallery and what you'd like your excerpt to look like, you may want to put limit="1" on the opening Matrix tag to prevent loading multiple captions.

  • Once again, Alex, you are right and this works fine. I surrounded my {if} statement with the tag for the matrix custom field (matrix_gallery) with a limit="1", and it works brilliantly. Feb 11, 2013 at 3:05

I'm not sure if EE's native search module provides an ID variable. If it did, you could use it in an embedded template to pull the matrix data in with a normal channel entries tag.

Looking at the docs for the search module ID doesn't appear to be a valid variable although it might still work, you'd have to test it out. If it doesn't, Low Search does give you access to all the variables that work with the Channel entries tag, so you might need to consider that as an alternative.

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.