Answers for "what is WP_Query in WordPress"

PHP
5

wp query

<?php 
// The Query
$the_query = new WP_Query( $args );
 
// The Loop
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 {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Posted by: Guest on September-27-2020
0

WP_Query

$query = new WP_Query( array( 'author__in' => array( 2, 6 ) ) );
Posted by: Guest on August-12-2021

Code answers related to "what is WP_Query in WordPress"

Browse Popular Code Answers by Language