Please disable your Ad Blocker to better interact with this website.

BLOG

See what we're whipping up!

// WP_Query arguments
$args = array(
    'post_type'              => array( 'post' ),
    'post_status'            => array( 'publish' ),
    'posts_per_page'         => '20',
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    $count = 0; // Added a variable to store our count
    while ( $query->have_posts() ) {
        $query->the_post();
        $count++; // Add +1 to the count variable each time we loop through our posts
        // do something like echo the title
    }
} else {
    // no posts found, uh oh!
}

// Restore original Post Data
wp_reset_postdata();

No comments yet