How can i order by a custom field in a channel entries tag?



I need to pull out all the entries in a channel that are of a certain type of category. But, i also want to be able to then sort the entries by the value of a custom field in that channel.

So right now, i have something like:

{exp:channel:entries channel="my_channel" limit="9" category="{segment_3_category_id}"}

And in that channel, i have a custom field of "price". I want to amend that channel tag to order by my custom field called "price".

How can i achieve this?


Posted 2012-11-22T16:10:28.673

Reputation: 1 411

To clarify for those reading the question, {segment_3_category_id} in the example code is a product of the Low Seg2Cat add-on.

– Derek Hogue – 2012-11-28T13:45:26.080



{exp:channel:entries channel="my_channel" orderby="price" sort="asc"}

Ordering entries by custom fields comes by default with ExpressionEngine:


Posted 2012-11-22T16:10:28.673

Reputation: 1 154

I have an issue.I have a points table and there are two teams locked at the same point.The one with more goals needs to be on top..any idea how that can be achieved? – None – 2014-06-01T10:38:55.393

you can pass multiple values to the "ordeby" parameter. So in your case this should do the trick: orderby="points|goals” – janvl – 2014-06-02T12:40:08.557

2Also, from the docs... The orderby= and sort= parameters can accept multiple values using the pipe character. This allows you to have multiple levels of ordering and then specify the sort rules for those levels, e.g. orderby="screen_name|date" sort="asc|desc" – Dave O'Brien – 2012-11-22T18:19:37.363


One addendum to the other answers (though they are perfectly correct) that may be relevant to you given your choice of sorting field:

It's worth noting that if you want your price field ordered data to be ordered numerically in order of increasing/decreasing scale, you will need to change the field content type to decimal (assuming decimal prices). To do this go into your field settings, and you'll find "Field Content" under the "Field Options" section.

Otherwise these values:


will end up sorted alphabetically like so:


when what you want is:


Tom Davies

Posted 2012-11-22T16:10:28.673

Reputation: 4 053


This is very easy to do Just order by your custom field - I do believe you are limited to fieldtype of "text" other fieldtypes won't work with the orderby parameter.


See the docs.


Posted 2012-11-22T16:10:28.673

Reputation: 4 048