How To Show Recent Posts On WordPress

Share Now

This code will help you to show recent posts on WordPress.
*** If you want to show all the post just use 'posts_per_page' => -1

<?php
    global $post;
    $args = array(
        'post_type'           => 'post',
        'posts_per_page'      => 4,
        'orderby'             => 'menu_order',
        'order'               => 'ASC',
    );
    $myposts = get_posts($args);
    foreach($myposts as $post):
    setup_postdata($post); 
?>

<!-- HERE YOU ADD YOUR POST BLOCK -->

<?php endforeach; wp_reset_query(); ?>

# From GISTS

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert