Last active
February 8, 2017 13:42
-
-
Save cagriuckan/a60129a7f2803d54eb41fea6c06e9ee9 to your computer and use it in GitHub Desktop.
How to Display a List of Last Updated Posts in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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