我想显示最近更新的帖子列表但不发布上次发布。同样,如何显示上次发布的列表但不显示上次更新?
答案 0 :(得分:0)
function display_updated_posts() {
/* These are the arguments to pass into WP_Query */
$modifiedposts_args = array('orderby' => 'modified', 'ignore_sticky_posts' => '1');
$modifiedposts_loop = new WP_Query( $modifiedposts_args );
$counter = 1;
echo '<ul>';
while( $modifiedposts_loop->have_posts() && $counter < 5 ) {
$modifiedposts_loop->the_post();
echo '<li><a href="' . get_permalink( $modifiedposts_loop->post->ID ) . '"> '
.get_the_title( $modifiedposts_loop->post->ID ) . '</a> ( '
. get_the_modified_date() .') </li>';
$counter++;
}
echo '</ul>';
wp_reset_postdata();
}
参考这个我希望这对你有帮助,
http://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-last-updated-posts-in-wordpress/