Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

WP_Wuery completo

WP_Query completa com todas as funcionalidades incluidas

// WP_Query arguments
$args = array (
	'p'                      => '$postID',
	'name'                   => '$postSLUG',
	'page_id'                => '$pageID',
	'pagename'               => '$pageSLUG',
	'post_parent'            => '$postCHILD',
	'post_type'              => '$post_TYPE',
	'post_status'            => '$post_STATUS',
	'cat'                    => '$categoryID',
	'category_name'          => '$categoryNAME',
	'tag_id'                 => '$tagID',
	'tag_name'               => '$tagNAME',
	'author'                 => '$authorID',
	'author_name'            => '$authorNAME',
	's'                      => '$searchKEY',
	'pagination'             => true,
	'paged'                  => '$paged_NUM',
	'posts_per_page'         => '$posts_per_PAGE',
	'posts_per_archive_page' => '$posts_per_arch_PAGE',
	'ignore_sticky_posts'    => true,
	'order'                  => 'DESC',
	'orderby'                => 'date',
	'meta_query'             => array(
		array(
			'key'       => '$custom_FIELD',
			'value'     => '$custom_FIELD_VAL',
			'compare'   => '=',
			'type'      => 'CHAR',
		),
	),
	'perm'                   => 'edit_posts',
);

// The Query
$listing_query = new WP_Query( $args );

// The Loop
if ( $listing_query->have_posts() ) {
	while ( $listing_query->have_posts() ) {
		$listing_query->the_post();
		// do something
	}
} else {
	// no posts found
}

// Restore original Post Data
wp_reset_postdata();