• I’ve seen this here on the forums and with a few changes I’ve got the following setup:

    <?php
      $cat_args = array('orderby' => 'name',
                        'order' => 'ASC');
      $categories = get_categories($cat_args);
      foreach($categories as $category) {
        $args = array('posts_per_page' => 5,
                      'category__in' => array($category->term_id),
                      'ignore_sticky_posts' => true );
        $posts = get_posts($args);
        if ($posts) {
          foreach($posts as $post) {
            setup_postdata($post);
            /* Post Loop */
          }
        }
      }
    ?>

    The thing is that I need the categories to be ordered by the latest post published. E.g. if new post is published in a category “abc” which is in position 7 it will be moved to position 1 and push all other categories down one.

    Does anybody have any idea how this could be done?

  • The topic ‘Sort categories by latest post published’ is closed to new replies.