Skip to content

Instantly share code, notes, and snippets.

@cagriuckan
Last active February 8, 2017 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cagriuckan/a60129a7f2803d54eb41fea6c06e9ee9 to your computer and use it in GitHub Desktop.
Save cagriuckan/a60129a7f2803d54eb41fea6c06e9ee9 to your computer and use it in GitHub Desktop.
How to Display a List of Last Updated Posts in WordPress
<?php
/**
* @link http://www.uckan.net/2017/02/08/wordpress-son-guncellenen-yazilari-listeleme/
* @package WordPress
* @uckannet
**/
function last_updated_posts () {
$args = array(
'ignore_sticky_posts' => '1',
'orderby' => 'modified',
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '';
echo ' - Last Modified:';
echo ''.the_modified_date().'</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment