To optimize performance, I'm trying to create an advanced entry query that selects only specific variables. I can set up the query to grab the entry title, uri, and a custom variable I created ("email" variable). But I don't know how to also select an asset as well. I basically want to create an advanced query that lets me publish the name, uri, email and asset (image variable called 'headshot').

Here's what I have. Just not sure what I need to also add in mu select to get my image asset.

{% set entries = craft.entries()
    .select('elements.id, elements_sites.uri, elements_sites.siteId, entries.sectionId, entries.typeId, content.id, content.title, content.email')
  • Does the entries have the asset field named "headshot"? – Kota.M Jul 19 '19 at 14:21
  • @Kota.M Yup, the asset field is "headshot." – user3092 Jul 19 '19 at 23:42
  • As far as I read the document (docs.craftcms.com/v3/dev/element-queries/entry-queries.html) it seems to be fine except for ")" is missing after the end of "with". – Kota.M Jul 22 '19 at 20:12
  • @Kota.M The missing ")" was a typo when I posted this. The code with the ")" doesn't work, unfortunately. – user3092 Aug 5 '19 at 22:55

Your Answer

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

Browse other questions tagged or ask your own question.