WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven: Help with custom loop (1 post)

  1. SteveEBoy
    Member
    Posted 2 years ago #

    Hi

    I decided to use the default "Twenty Eleven" theme and I'm trying to customise the "other recent posts" loop. By default the loop simply lists all recent posts chronologically. What I'd like to do is group them by category. I've failed to achieve this so far and wondered if anyone could offer some pointers.

    What I've got so far is a series of loops (1 for each category) using WP_Query as follows:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    As you can see I've had to hard code each category in this loop which isn't very good - what if I add new categories etc.

    What I'd like to achieve is some order in the loop by grouping the recent posts by category along the lines:

    category: category 1 (a label)
    Post 1 in category 1 (the posts)
    Post 2 in category 1
    etc

    Category: category 2 (the next category label)
    Post 1 in category 2 (the posts)
    Post 1 in category 2
    etc

    Can anyone offer some pointers on how I might tackle this please ?

    You can see the loops I've got so far at: http://www.riotstories.co.uk

    Thanks for any help

Topic Closed

This topic has been closed to new replies.

About this Topic