query post code example
Example 1: wp query
<?php
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
}
wp_reset_postdata();
Example 2: wp_query to get posts
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'future'
);
$scheduled = new WP_Query( $args );
if ( $scheduled->have_posts() ) :
?>
<?php while( $scheduled->have_posts() ) : $scheduled->the_post() ?>
<!
<?php endwhile ?>
<?php else : ?>
<!
<?php endif ?>