WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sort category list by date (5 posts)

  1. ShadyCraig
    Member
    Posted 9 years ago #

    Anyone know a way of sorting categories by the date (of the newest post)?
    Can't find a tag to do it or any plugins.

    Site at:
    Devine Projects News

    Cheers,

  2. ShadyCraig
    Member
    Posted 9 years ago #

    Ok I suppose not!

    Well I'll post on here any solution I find...

    see ya
    ShadyCraig

  3. ShadyCraig
    Member
    Posted 8 years ago #

    Well I managed to get something working.

    The concept is that the category with the newest post will be show first, with it's 4/5 newest posts, aftter that the category with the next newest post will be shown with it's newest posts ... and etc

    See the results here: http://www.devineprojects.org/news/

    <?php
    $thiscat='';
    $newestcat[3];
    $i=0;
    $j=0;
    ?>
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

    <?php
    if (is_home()) {

    if ($i<3) {
    foreach((get_the_category()) as $cat) {
    }
    $thiscat=$cat;
    for ($j=0;$j<=$i;$j++){
    if ($thiscat->cat_ID!=$newestcat[i])
    {
    $newestcat[i] = $thiscat->cat_ID;
    echo "$thiscat->cat_name<br/>";
    c2c_get_recent_posts(
    4, "
    <li>%post_URL% @%post_date% (%comments_count%)<br>%post_excerpt_short%</br></li>
    ", $i, 'date', 'DESC', 0, 'd/m/Y'
    );
    $i++;
    $j++;
    }
    }
    }

    } else {
    ?>

  4. Kafkaesqui

    Posted 8 years ago #

    You might also want to see my Display by Category home.php template:

    http://wordpress.org/support/topic/38046

  5. ShadyCraig
    Member
    Posted 8 years ago #

    Cheers Kafkaesquí,

    I'll check that out!

Topic Closed

This topic has been closed to new replies.

About this Topic