DEVTOOLS

WP_Query Generator

Configure your WordPress query using the fields below. Choose post type, sort order, status, meta conditions, and taxonomy filters — then copy the generated PHP or Blade code directly into your theme or plugin.

Query Parameters
Basic
meta_query

No meta query rows.

tax_query

No tax query rows.

Generated Code
$args = [
    'post_type'      => 'post',
    'posts_per_page' => 10,
    'orderby'        => 'date',
    'order'          => 'DESC',
    'post_status'    => 'publish',
];
$query = new WP_Query( $args );

if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post();
        // your loop content here
    endwhile;
    wp_reset_postdata();
endif;