We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Is there a way to have both | and & separated parameters in an entry loop?

How Do I?

chesterblack's avatar
chesterblack
5 posts
5 years ago
chesterblack's avatar chesterblack

I would like to show only entries that have either category 1 or 2 and either 3 or 4. Something along the lines of: {exp:channel:entries category="(1|2)&(3|4)"}

Is there any way of doing this? The only way I can think of is by doing one group, and then passing through the entry_ids of the results into an embed that then specifies the second group along with the entry_ids. i.e.

{!-- Main template --}
{embed="embed" 
    entries="
        {exp:channel:entries category='1|2'}
            {entry_id}|
        {/exp:channel:entries}
"}
{!-- Embedded template --}
{exp:channel:entries category="3|4" entry_id="{embed:entries}"}
    {!-- Do stuff --}
{/exp:channel:entries}

But this seems very messy (and I’m not really sure if that whole loop-inside-an-embed thing will even work)

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

Tricky. I like the idea of that syntax, but it’s just not going to work (category=”(1|2)&(3|4)). I also don’t think category="3|4" entry_id="{embed:entries}" will work- you can embed it, but I expect it’s still going to work like an ‘and’.

One option would be to use the query module and get all of the entry ids that meet your category requirements (query exp_category_posts) and send that over as an embed variable. That would work. You can just use the normal parameters in the tag with the embed to make sure the entries are in the correct status, date range, etc.

That would be my first option.

       
chesterblack's avatar
chesterblack
5 posts
5 years ago
chesterblack's avatar chesterblack

Yeah, I think using a query is going to be my best bet, thanks!

? 1
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.