WordPress WP_Query Generator
Visually build custom WordPress PHP loop queries and arguments without digging through the Codex every time.
Generated PHP Code
<?php
// The Query Parameters
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 10,
'order' => 'DESC',
'orderby' => 'date',
);
// The Query
$custom_query = new WP_Query( $args );
// The Loop
if ( $custom_query->have_posts() ) {
while ( $custom_query->have_posts() ) {
$custom_query->the_post();
// do something
?>
<h2><?php the_title(); ?></h2>
<div><?php the_excerpt(); ?></div>
<?php
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
?>