logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$20
How can I display category summaries according to freshness?

For a new theme, I want to display category summary boxes (1 excerpt + 3 headlines) similar to what you see in the center column of Mimbo Pro.

But -- I want to display just 3 category summary boxes, ordered by whichever category was updated last. Can this be done?

This question has been answered.

Darren Hoyt | 12/31/09 at 2:05am Edit


(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    01/02/10
    4:50pm
    Max says:

    Hi Darren,

    I think that the most efficient way of doing this is with a raw mysql query:



    select wp_term_taxonomy.term_taxonomy_id from wp_posts, wp_term_relationships, wp_term_taxonomy WHERE taxonomy='category' AND wp_term_taxonomy.term_taxonomy_id=wp_term_relationships.term_taxonomy_id AND object_id=wp_posts.ID AND post_type='post' AND post_status='publish' order by post_date DESC LIMIT 20;



    This query returns the last updated categories taking in consideration the last 20 post published.

    Then you could select a subset of the three distinct categories at the top of this result set and run a loop for each of them. You know best:

    query_posts('cat=n&posts_per_page=4');


    Hope this help.
    Happy new year!

    Max

  • avatar
    Last edited:
    01/02/10
    4:50pm
    Tom Ransom says:

    I can't take credit for the code (see: Last Updated Categories WordPress 2.3 Query from Devlounge )

    but:


    function getAllCats() {
    global $wpdb;
    $query = "select t.term_id as term_ids, t.name, t.slug, max(p.ID) as id, tx.count from $wpdb->terms t, $wpdb->term_taxonomy tx, $wpdb->term_relationships tr, $wpdb->posts p where t.term_id = tx.term_id and tx.taxonomy = 'category' and tr.term_taxonomy_id = t.term_id and tr.object_id = id and p.post_status = 'publish' group by term_ids order by id desc";
    $results = $wpdb->get_results($query);
    foreach ($results as $result) {
    $catPermalink = get_bloginfo('url') . "/category/" . $result->slug . "/";
    ?>
    <li><a href='<?php echo $catPermalink ?>'><?php echo $result->name ?></a></li>
    <?php
    }
    }

    Previous versions of this answer: 01/02/10 at 12:10pm

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.