wp query search 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 search
$query = new WP_Query( array( 's' => 'keyword' ) );