Home » Posts latest to oldest

Posts latest to oldest

[insert_php]
$args = array(
‘post_type’=> ‘post’,
‘orderby’ => ‘date’,
‘post_status’ => ‘publish’,
‘order’ => ‘DESC’,
‘posts_per_page’ => -1 // this will retrive all the post that is published
);
$post_str = “”;
$post_count = 0;

$result = new WP_Query( $args );
if ( $result->have_posts() ) :;
while ( $result->have_posts() ) : $result->the_post();
$ptitle = get_the_title();

$link = get_the_permalink();
$pdate = get_the_date();
$post_str .= “$pdate $ptitle“;
$post_str .= “\n”;
$post_count = $post_count + 1;
endwhile;
endif;
echo “Total posts: $post_count\n\n”;
echo $post_str;
wp_reset_postdata();
[/insert_php]

Recent Posts

September 2020
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
282930  

Topics