Wp Query All args

All Args for your next query!


$args = array(
// Author Parameters - Show posts associated with certain author.
'author' => '1,2,3,',
'author_name' => 'luetkemj',
'author__in' => array( 2, 6 ),
'author__not_in' => array( 2, 6 ), 

// Category Parameters - Show posts
'cat' => 5, // (int)
'cat' => '-12,-34,-56'
'category_name' => 'staff, news',
'category_name' => 'staff+news',
'category__and' => array( 2, 6 ),
'category__in' => array( 2, 6 ),
'category__not_in' => array( 2, 6 )

// Tag Parameters - Show posts associated with certain tags.
'tag' => 'cooking', // (string)
'tag_id' => 5, // (int)
'tag__and' => array( 2, 6), // (array)
'tag__in' => array( 2, 6), // (array)
'tag__not_in' => array( 2, 6), // (array)
'tag_slug__and' => array( 'red', 'blue'),
'tag_slug__in' => array( 'red', 'blue'),

// Taxonomy Parameters - Show posts associated with certain taxonomy.

'tax_query' => array
'relation' => 'AND',
array(
'taxonomy' => 'color',
'field' => 'slug',
'terms' => array( 'red', 'blue' ),
'include_children' => true,
'operator' => 'IN'
),
array(
'taxonomy' => 'actor',
'field' => 'id',
'terms' => array( 103, 115, 206 ),
'include_children' => false,
'operator' => 'NOT IN'
)
),

// Post & Page Parameters - Display content based on post and page parameters.
'p' => 1,
'name' => 'hello-world',
'title' => 'Hello World'
'page_id' => 1, // (int)
'pagename' => 'sample-page',
'pagename' => 'contact_us/canada',
'post_name__in' => 'sample-post' (array)
'post_parent' => 1,
'post_parent__in' => array(1,2,3)
'post_parent__not_in' => array(1,2,3),
'post__in' => array(1,2,3),
'post__not_in' => array(1,2,3),

// Password Parameters - Show content based on post and page parameters. Remember that default post_type is only set to display posts but not pages.
'has_password' => true, // (bool) - available with Version 3.9
// true for posts with passwords;
// false for posts without passwords;
// null for all posts with and without passwords
'post_password' => 'multi-pass', // (string) - show posts with a particular password (available with Version 3.9)

// Post Type Parameters - Show posts associated with certain type or status.
'post_type' => array
'post',
'page',
'revision',
'attachment',
'nav_menu_item'
'my-custom-post-type',
),

'post_type' => 'any', 

// Post Status Parameters
'post_status' => array( // (string | array)
'publish', .
'pending',
'draft',
'auto-draft',
'future',
'private',
'inherit',
'trash',
),

'post_status' => 'any', 

// Comment Paremters - @since Version 4.9 Introduced the `$comment_count` parameter.
'comment_count' => 10
'comment_count' => array(
'value' => 10 // (int)
'compare' => '='
// Note: if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option.
'nopaging' => false, // (bool) - show all posts or use pagination. Default value is 'false', use paging.
'paged' => get_query_var('paged'), // (int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
'nopaging' => false, // (boolean) - show all posts or use pagination. Default value is 'false', use paging.
'posts_per_archive_page' => 10, // (int) - number of posts to show per page - on archive pages only.
'offset' => 3, // (int)
'paged' => get_query_var('paged')
'page' => get_query_var('page'), 

// Order & Orderby Parameters - Sort retrieved posts.
'order' => 'DESC', 

//Possible Values:
//'ASC'
//'DESC'
'orderby' => 'date',
EX: 'orderby' => 'menu_order title'
//Possible Values:
// 'none' - No order (available since Version 2.8).
// 'ID' - Order by
// 'author'
// 'title'
// 'name'
// 'type'
// 'date'
// 'modified'
// 'parent'
// 'rand'
// 'comment_count'
// 'relevance'
// 'menu_order'
// 'meta_value'
// 'meta_type'
// 'meta_value_num'
// 'post__in'
// 'post_name__in'
// 'post_parent__in'

// Date Parameters - Show posts associated with a certain time and date period.
'year' => 2014,
'monthnum' => 4,
'w' => 25,
'day' => 17,
'hour' => 13,
'minute' => 19,
'second' => 30,
'm' => 201404,
'date_query' => array( // (array) - Date parameters 

array(
'year' => 2014,
'month' => 4,
'week' => 31,
'day' => 5,
'hour' => 2,
'minute' => 3,
'second' => 36,
'after' => 'January 1st, 2013', //
'before' => array( // (string/array)
'year' => 2013,
'month' => 2,
'day' => 28,
),
'inclusive' => true,
'compare' => '=',
Default value is '='
'column' => 'post_date',
'relation' => 'AND',
),
),

// Custom Field Parameters - Show posts associated with a certain custom field.
'meta_key' => 'key',
'meta_value' => 'value'
'meta_value_num' => 10
'meta_compare' => '=',
'meta_query' => array
'relation' => 'AND',
array(
'key' => 'color',
'value' => 'blue',
'type' => 'CHAR', 

'compare' => '=',
),
array(
'key' => 'price',
'value' => array( 1,200 ),
'compare' => 'NOT LIKE',
)
),

// Permission Parameters - Display published posts, as well as private posts, if the user has the appropriate capability:
'perm' => 'readable',

// Mime Type Parameters - Used with the attachments post type.
'post_mime_type' => 'image/gif', // (string/array) - Allowed mime types.

// Caching Parameters
// NOTE Caching is a good thing. Setting these to false is generally not advised.
'cache_results' => true,
'update_post_term_cache' => true,
'update_post_meta_cache' => true,
'no_found_rows' => false

// Post Field Parameters
'fields' => 'ids',
// Possible values:
// 'ids'
// 'id=>parent'
// Passing anything else will return all fields (default) - an array of post objects.
// Filters

);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
// Do Stuff
endwhile;
endif;
// Reset Post Data
wp_reset_postdata();
?>

<pre>