• If I want to show last updated post (have new comment, edited), instead of recent post, then what post loop may I use?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi ftfarhad.
    Below simple function will help you on the same.

    <?php
         $today = current_time('mysql', 1);
         $count = 5;
         if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $count")):
    ?>
    <h2><?php _e("Recent Updates"); ?></h2>
    
    <ul>
    <?php
    foreach ($recentposts as $post) {
         if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
         echo "
    <li><a>ID)."'>";
         the_title();
         echo '</a></li>
    ';
    }
    ?>
    </ul>
    <?php endif; ?>

    let me know if you need more help ??

    Thread Starter ftfarhad

    (@ftfarhad)

    Where I use this code? in the loop or functions.php?

    Wherever you want display latest updated posts. just paste this code there

    Thread Starter ftfarhad

    (@ftfarhad)

    Thanks. If any one comment a post which was created 1 year ago, then it will show in homepage?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘last edited or updated post’ is closed to new replies.