Forums

Posts updated (4 posts)

  1. shadow
    Moderator
    Posted 5 years ago #

    Hi,
    I have had a good look through the forums and the Wiki, but can't find exactly what I am looking for.
    Has anyone seen a plugin that allows for showing the latest posts that have been updated?
    Thanks for any advice :)

  2. oriecat
    Member
    Posted 5 years ago #

    By updated, I assume you mean edited?
    Ok, just for fun, I decided to see if I could do this. On one of my sites, I have been using a Recent Posts hack. So I modified it to pull posts where the post_date < post_modified. At first I got an error but then I edited a post (in case there were none for it to pull!) and it seems to work. See here: http://moltenwords.net/pp101/ It says Recent Posts, but I didn't change that.
    Here is the code I used:
    <?php
    function get_edited_posts($no_posts = 5, $before = '

  3. ', $after = '
  4. ', $show_pass_post = false, $skip_posts = 0) {
    global $wpdb, $tableposts;
    $request = "SELECT ID, post_title FROM $tableposts WHERE post_date < post_modified ";
    if(!$show_pass_post) { $request .= "AND post_password ='' "; }
    $request .= "ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
    $posts = $wpdb->get_results($request);
    $output = '';
    foreach ($posts as $post) {
    $post_title = stripslashes($post->post_title);
    $permalink = get_permalink($post->ID);
    $output .= $before . '' . $post_title . '' . $after;
    }
    echo $output;
    }
    ?>

    It would go in your my-hacks file, then on the index.php you would need to include <?php get_edited_posts(); ?> where you want them to be.
    This is my first attempt at modifying anything like this, so I make no guarantees. :)

  • shadow
    Moderator
    Posted 5 years ago #

    Thanks Oriecat:)
    I will have a play with it later today and see how it goes.

  • dannyman
    Member
    Posted 5 years ago #

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.