Is there a better (less server intensive therefore slow) way to retrieve entries based on a category setting i.e. this is what we currently use:-

 {exp:channel:categories channel="products" style="linear"}
    {if show_in_main_menu == "Yes"}
      {exp:gwcode_categories cat_id="{category_id}" incl_self="no" style="linear" disable="member_data|pagination|categories|category_fields"}
        [ENTRY DATA]

This currently takes about 3 seconds per iteration on our site (and we have to do something similar in 2 other locations) so we're getting ~10 second page load times which the client isn't happy about!


Looping through categories and outputting entries within is an inherently "expensive" process. Someone will likely pipe in here with an answer that uses Stash to optimize this, but I'd suggest two options:

  1. Use CE Cache to cache this area of your template.
  2. Use NSM Categories to output your entries grouped by category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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