I am using this code snippet to create a list of recently modified posts:

function wpb_lastupdated_posts() { 

// Query Arguments
$lastupdated_args = array(
     'orderby' => 'modified',
     'ignore_sticky_posts' => '1'

//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> ( '. get_the_modified_date() .') </li>';
    echo '</ul>';

//add a shortcode
add_shortcode('lastupdated-posts', 'wpb_lastupdated_posts');

The result is here:


However, I would like to have the format:

Category - Post title - Author - Modified date.

I am not a programmer and my attempts to hack the code have not worked. Any help most appreciated!

  • Maybe start by formatting your code properly. It's unreadable in the current way. – kaiser Jan 25 '14 at 0:04
  • I got the code from here: wpbeginner.com/wp-tutorials/… – Mark Devlin Jan 25 '14 at 0:20
  • It doesn't really matter where you got the code from. It's unreadable. Please file an edit and reformat it. – kaiser Jan 25 '14 at 0:29
  • Does that help? I am not a programmer so I am not sure of the appropriate format. – Mark Devlin Jan 25 '14 at 2:18
  • A bit, yes. I hope you're aware of the fact that this site is dedicated to development, so you'll have to be ready to read and understand code when you get an answer. There won't be anyone holding your hand and providing a copy/paste solution. – kaiser Jan 25 '14 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.