WordPress.org

Forums

Display Recently Modified/Updates Posts but.... (1 post)

  1. jeriksson
    Member
    Posted 9 months ago #

    Hi,

    I need a script to display recently modified/updated posts, this code does this:

    //Loop to display 5 recently updated posts
    $lastupdated_loop = new WP_Query( $lastupdated_args );
    $counter = 1;
    echo '<ul>';
    while( $lastupdated_loop->have_posts() && $counter < 5 ) : $lastupdated_loop->the_post();
    echo '<li><a href="' . get_permalink( $lastupdated_loop->post->ID ) . '"> ' .get_the_title( $lastupdated_loop->post->ID ) . '</a><br> ( '. get_the_modified_date() .') </li>';
    $counter++;
    endwhile;
    echo '</ul>';
    wp_reset_postdata();
    } 
    
    //add a shortcode
    add_shortcode('lastupdated-posts', 'wpb_lastupdated_posts');

    however.... it also displays if i make a completely new post as a new update, i need it to only display modifications made to posts that have already been posted previously.

    anyone know if there's a built in function in wordpress to do this?

Reply

You must log in to post.

About this Topic

Tags

No tags yet.