I have two entry types in a same structure, I want to get some values from these two types in a same page. Is it possible?

I tried:

{% set entry = craft.entries.section('businessProfile').type(['type1','type2]) %}

And the entry.type still shows only one type. Thanks in advance!

  • You can fetch all entry type when you just leave don't include .types. Besides that your command is missing an ' otherwise it is totally correct. Apr 4 '18 at 6:10

And just to make sure: you are iterating over the results, right? because it actually should be:

{% set entries = craft.entries.section('businessProfile').type(['type1','type2]).all() %} {% for entry in entries %} ... ... Here {{entry.type}} should be different {% endfor %}

  • Sorry man, it doesn't work. It's like only one entry type can be reached at one time. Because when I change the type and save it, the type will be shown. And when I switch to the other type and save, the result change to that type.
    – yu xia
    Apr 4 '18 at 21:44
  • But you have more entries in your section than one don't you? Apr 4 '18 at 22:26
  • @RobinSchambach Yes, I have two entries under the section.
    – yu xia
    Apr 5 '18 at 3:11
  • @yuxia do you expect to get both types in the entry.type function? Because it will only return you the current selected type Apr 5 '18 at 6:07
  • @RobinSchambach Yeah, I wanna get some values from both entry types at the same time. But now it's like impossible
    – yu xia
    Apr 5 '18 at 22:06

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.