Last updated 4 years ago
<?php $args = array( 'post_type' => array( "product" ), 'post_status' => array( 'publish' ), 'posts_per_page' => 2 ); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); echo get_the_title() . '<br/>'; endwhile; endif; wp_reset_postdata(); ?>