WP Post Query Based On Date

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email
<?php
$args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC',
    'ignore_sticky_posts' => 1,
    'suppress_filters' => true,
    'posts_per_page' => 3

);
$loop = new WP_Query($args);
while ($loop->have_posts()):
    $loop->the_post();

    $blg_featured_img = get_the_post_thumbnail_url();
    if (empty($blg_featured_img))
    {
        $blg_featured_img = "/wp-content/uploads/inf-2.jpg";
    }
?>
<?php echo $blg_featured_img; ?>
<?php the_permalink(); ?>
<?php echo get_the_date(); ?>
<?php the_title(); ?>
<?php endwhile; wp_reset_postdata(); ?>
Nahid Mahamud

Nahid Mahamud

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