Search code examples
htmlcontent-management-systemexpressionengine

ExpressionEngine ordering entries inside of a category tag


I have a blog where I display recent posts in my sidebar. I use this code to get all of my entries

{exp:channel:categories style="linear" category_group="2"}
     {exp:channel:entries channel="article" category="{category_id}" orderby="entry_date" sort="desc" dynamic="off"}
        <li><a href="{site_url}{category_url_title}/{url_title}">{title}</a></li>
    {/exp:channel:entries}
{/exp:channel:categories}

This works to display my entries, but the ordering is in correct. It displays the order of the entries in order of the categories.

How can I ignore the category order?


Solution

  • You can't with that loop as its going to process it by category first and foremost, then the entries in that category, I would think this would work:

    {exp:channel:entries channel="article" category_group="2" orderby="entry_date" sort="desc" dynamic="off"}
        <li>
            <a href="{site_url}{categories}{category_url_title}{/categories}/{url_title}">{title}</a>
        </li>
    {/exp:channel:entries}
    

    Assuming the entry is only classified in one category, you shouldn't have any problems.