0

I would like to display a list of my last modified posts in the sidebar and the modification date in front of them.

<?php
$args = array( 'numberposts' => '5', 'orderby' => 'ID', 'post_status' => 'publish', 'category__not_in' => array(523) );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><b>'.get_the_modified_date('d/m').'</b> <a href="' . get_permalink($recent["ID"]) . '" title="'.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
}
?>

This result in showing the same modified date for all of them...

4

1 回答 1

1

你可以这样orderbypost_modified

<?php
$args = array( 'numberposts' => '5', 'orderby' => 'post_modified', 'post_status' => 'publish', 'category__not_in' => array(523) );
$recent_posts = get_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><b>'.$recent->post_modified.'</b> <a href="' .get_permalink($recent->ID) . '" title="'.esc_attr($recent->post_title).'" >' .   $recent->post_title.'</a> </li> ';
}
?>
于 2013-06-25T09:55:34.880 回答