wp query post per page code example

Example 1: wp query

have_posts() ) {
    echo '
    '; while ( $the_query->have_posts() ) { $the_query->the_post(); echo '
  • ' . get_the_title() . '
  • '; } echo '
'; } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata();

Example 2: wp_query to get posts

 'post',
	'post_status' => 'future'
);
$scheduled = new WP_Query( $args );

if ( $scheduled->have_posts() ) : 
?>
	have_posts() ) : $scheduled->the_post() ?>
		
	

	

Example 3: wp query search

$query = new WP_Query( array( 's' => 'keyword' ) );

Tags: