Basic Loop using WP_Query

Full Documentation – https://developer.wordpress.org/reference/classes/wp_query/

<?php
wp_reset_query();
$args = [
     'post_type'      => 'post',
     'post_status'    => 'publish',
     'posts_per_page' => -1,
	 'no_found_rows'  => true, // don't return total rows, helps with performance.
	 //'fields'         => 'ids', // only return post id's, helps with performance
];
$custom_query = new WP_Query( $args );
?>
<?php if ( $custom_query->have_posts() ) : ?>
     <?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>

     <?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php endif;