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

Secondary Sort on Channel Entries

How Do I?

unknown_'s avatar
unknown_
2 posts
one year ago
unknown_'s avatar unknown_

Hi,

I’m having an issue with sorting channel entries by two fields.

My code is the following:

{exp:channel:entries channel="properties" dynamic="no" orderby="title|channel_field" sort="asc"}

When I order by just title or just channel field, it works as intended. But when doing both nothing happens, it just uses the first (before the pipe character).

Any help massively appreciated.

       
unknown_'s avatar
unknown_
2 posts
one year ago
unknown_'s avatar unknown_

Managed to find the solution to this.

EE doesn’t like if you do title + channel field apparently. I changed the orderby to be “channel_field|channel_field” and its now working as intended.

Did mean that I had to create another field in the backend just called “display_title” but all is now good.

       
Rob Allen's avatar
Rob Allen
3,105 posts
one year ago
Rob Allen's avatar Rob Allen

You probably need a second sort value to match the two orderby values, e.g. orderby="title|channel_field" sort="asc|desc"

       
troylewis's avatar
troylewis
5 posts
one year ago
troylewis's avatar troylewis

Thanks for your method. It works well

       
Tony18's avatar
Tony18
1 posts
one year ago
Tony18's avatar Tony18

The issue is likely that ExpressionEngine’s orderby doesn’t support multiple fields with the pipe. Try sorting by one field at a time, or if you need multiple sorts, consider using custom logic or a plugin. Alternatively, you could manually combine fields in a custom field for sorting.

       

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.