Support » Plugins » Modified Version Recently Updated Posts

  • Resolved macmiller


    During the upgrade to 2.3.1 several plug-ins I was using stop working. One was Show Category Posts which I was using to display information on recent blog posts on my non-blog homepage.

    See related posts:
    topic 148851
    topic 148850
    topic 148761

    I found a working method to accomplish what I am trying to do and decided to put up a separate thread to share it as opposed to putting in each of the above.

    First off, there was a good suggestion to just do this:

    <?php wp_get_archives("type=postbypost&limit=20"); ?>

    Note: remember to put

    /* Don't remove this line. */

    at the top of your non-blog page.

    This will return a list of recent posts and works fine just by inserting this in your non-blog page. However, it returns only the post_title as a link. In my case I wanted the post_title, post_date and post_excerpt to display.

    The easiest way I found to get this information out is to modify a plug-in that works for 2.3.1. It is Recently Updated Posts. In it’s existing form it returns only a list of posts based on last mod date, I tweaked it to return the post, date, and excerpt and sort it on post date (as opposed to modified date).

    Here is what I changed:

    The foreach loop, changed to format date, and return date/excerpt:

    foreach($posts as $p) {
    		$title_ = str_replace('-', '- ', $p->post_title);
                    $tdYYYY = substr($p->post_date,0,4);
                    $tdMM = substr($p->post_date,5,2);
                    $tdDD = substr($p->post_date,8,2);
                    $ttHH = substr($p->post_date,11,2);
                    $ttMM = substr($p->post_date,14,2);
                    $ttSS = substr($p->post_date,17,2);
                    $tfmtdatetime = date('d-M-Y', mktime($ttHH, $ttMM, $ttSS, $tdMM, $tdDD, $tdYYYY));
    		print '<li>'.'<a href="'.get_permalink($p->ID).'" title="'.htmlentities($p->post_title).'">'.$title_.'</a>' . ' - ' . $tfmtdatetime . '</li>';
                    print '<li>' . '  ' . $p->post_excerpt . '</li>';

    SQL select statement: I changed to select all the data fields (SELECT *) and to sort by post_date_gmt.

    $sql = "SELECT * FROM'{$wpdb->posts}'"
    		. " WHERE 'post_status' = 'publish'"
    		. " AND 'post_modified_gmt' != '0000-00-00 00:00:00'"
    		. ($includePages
    			? " AND ('post_type' = 'post' OR <code>post_type</code> = 'page')"
    			: " AND 'post_type' = 'post'")
    		. ($hideProtectedPosts
    			? " AND 'post_password' = ''" : '')
    		. " AND 'post_modified_gmt' < '{$now}'"
    		. " ORDER BY 'post_date_gmt' DESC"
    		. " LIMIT {$skip}, {$no_posts}";

    I found this plugin was quite small and easy to tweak.

Viewing 1 replies (of 1 total)
  • does this display the title, date, and excerpt from a specific category? that’s what I’m trying to do, but haven’t had any luck finding a way to do it….see my post here

Viewing 1 replies (of 1 total)
  • The topic ‘Modified Version Recently Updated Posts’ is closed to new replies.