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

Limit parameter for relationships tag?

How Do I?

Nelly's avatar
Nelly
81 posts
5 years ago
Nelly's avatar Nelly

After reading the docs, it appears that the relationships template tag has no limit option (for multiple relationship fields). Is this correct?

I need to present only two related entries, and no more, so in that case, it might be easier to use two single relationship fields instead.

Thanks!

       
Rob Allen's avatar
Rob Allen
2,950 posts
5 years ago
Rob Allen's avatar Rob Allen

Are you talking about “parents” or “children” relationships?

If you’re using parents the limit parameter has always worked for me:

{exp:channel:entries channel="mychannel" limit="1"}

{title}

{parents channel="otherchannel" limit="3" orderby="entry_date" sort="desc"}    
  {parents:title}
{/parents}

{/exp:channel:entries}
? 1
       
Nelly's avatar
Nelly
81 posts
5 years ago
Nelly's avatar Nelly

Children relationships, but I’m glad to know it works on parents, as it might also work for children.

I haven’t tested it myself because I have to create test entries to do so, but will do and report back. Thanks, Rob!

       
Rob Allen's avatar
Rob Allen
2,950 posts
5 years ago
Rob Allen's avatar Rob Allen

Ah ok, for child relationships it’s worth adding the limit= parameter to see if it works (sometimes odd bits like this work but aren’t documented).

With a relationship field it’s normally up to the author as to how many entries to relate which is why the limit= parameter may not exist for children, but I can see the use case for it.

       

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.