Iam having a dropdown field with fixed options.

Let’s say it is {fruits} with options Apple, Pineapple, Banana and Orange

I need to output how many channel entries are there corresponding to each option, next to it.

e.g. Apple (10) Pineapple (20) Banana (5) Orange (15)

As you have guessed there are a total of 50 rows for the field {fruits}

How can I do that?


  • How are you maintaining a count? If there are 10 apples, is it because there are 10 channel entries with that field set to apple?
    – jrothafer
    May 10, 2015 at 16:49
  • Yes, it is because there are 10 channel entries with value 'Apple' for field {fruits}
    – Noor M
    May 11, 2015 at 2:14

1 Answer 1


Try this? (Not going to be next to an EE install for a few days, can't test):

There are
{exp:query sql="SELECT field_id_X as fruit, COUNT(fruit) FROM exp_channel_data GROUP BY fruit" backspace="2"}
{count} {fruit}(s), 

And you just have to replace field_id_X with the field name from your exp_channel_data table that corresponds to that field.

  • Thank you. However, it did not work. What I wanted to do was this ` {exp:channel:entries channel="items" search:fruits="=Apple"}Apple ({absolute_count}){/exp:channel:entries}` What is happening is, if there are 3 channel entries for Apples .. it is outputting Apples (3)(3)(3) What I need is Apples (3)
    – Noor M
    May 11, 2015 at 4:39
  • Got it working by this code {exp:query sql="SELECT COUNT(field_id_X) AS fruit FROM exp_channel_data WHERE field_id_X = 'Apples' GROUP BY field_id_X"}({fruit}){/exp:query} Replaced X with the correct number from the table. Thanks for the heads up @jchrono-battle
    – Noor M
    May 11, 2015 at 6:15
  • Glad you got it! Yeah, I always have to type SQL queries out a few times at a CLI to get them right, not surprised it needed adjusting.
    – jrothafer
    May 11, 2015 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.