Skip to content

Instantly share code, notes, and snippets.

@th3d0g
Forked from luetkemj/wp-query-ref.php
Created January 10, 2013 11:19

Revisions

  1. @luetkemj luetkemj revised this gist Sep 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wp-query-ref.php
    Original file line number Diff line number Diff line change
    @@ -91,7 +91,7 @@
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
    '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.
    //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.
    //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.



  2. @luetkemj luetkemj renamed this gist Sep 17, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @luetkemj luetkemj revised this gist Sep 17, 2012. 2 changed files with 0 additions and 190 deletions.
    File renamed without changes.
    190 changes: 0 additions & 190 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,190 +0,0 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated ba slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'my-post-type', // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft', // - a newly created post, with no content.
    'future', // - a post to publish in the future.
    'private', // - not visible to users who are not logged in.
    'inherit', // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    ),

    //NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
    'post_type' => 'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'post_status' => 'any', // - retrieves any status except those from post types with 'exclude_from_search' set to true.



    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
    '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.
    //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The quer variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.



    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaultto 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the EdiPage Attributes box) and for Attachments (the integer fields in the Insert / Upload MediGallery dialog), but could be used for any post type with distinct 'menu_order' values (theall default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note alsthat the sorting will be alphabetical which is fine for strings (i.e. words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also notthat a 'meta_key=keyname' must also be present in the query. This value allows for numericasorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => false, //(bool) - ignore sticky posts or not. Default value is false, don't ignore. Ignore/excludsticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order othat list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or ='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilitiealthough I have not tested)

    //////Parameters relating to caching
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order timplement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not tcount the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more informatiosee: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true, //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Search Parameter
    's' => $s, //(string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    'exact' => true //(bool) - flag to make it only match whole titles/posts - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
    'sentance' => true //(bool) - flag to make it do a phrase search - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
  4. @luetkemj luetkemj revised this gist Sep 17, 2012. No changes.
  5. @luetkemj luetkemj revised this gist Sep 17, 2012. 1 changed file with 190 additions and 0 deletions.
    190 changes: 190 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,190 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated ba slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'my-post-type', // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft', // - a newly created post, with no content.
    'future', // - a post to publish in the future.
    'private', // - not visible to users who are not logged in.
    'inherit', // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    ),

    //NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
    'post_type' => 'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'post_status' => 'any', // - retrieves any status except those from post types with 'exclude_from_search' set to true.



    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
    '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.
    //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The quer variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.



    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaultto 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the EdiPage Attributes box) and for Attachments (the integer fields in the Insert / Upload MediGallery dialog), but could be used for any post type with distinct 'menu_order' values (theall default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note alsthat the sorting will be alphabetical which is fine for strings (i.e. words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also notthat a 'meta_key=keyname' must also be present in the query. This value allows for numericasorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => false, //(bool) - ignore sticky posts or not. Default value is false, don't ignore. Ignore/excludsticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order othat list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or ='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilitiealthough I have not tested)

    //////Parameters relating to caching
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order timplement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not tcount the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more informatiosee: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true, //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Search Parameter
    's' => $s, //(string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    'exact' => true //(bool) - flag to make it only match whole titles/posts - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
    'sentance' => true //(bool) - flag to make it do a phrase search - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
  6. @luetkemj luetkemj renamed this gist Sep 17, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @luetkemj luetkemj renamed this gist Sep 17, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -90,8 +90,10 @@ $args = array(
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you dget_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.
    '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.
    //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.



    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.
  8. @luetkemj luetkemj renamed this gist Apr 30, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. @luetkemj luetkemj renamed this gist Apr 30, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -162,8 +162,8 @@ $args = array(

    //////Search Parameter
    's' => $s, //(string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    'compare' => '=', //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    'sentance' => true //(bool) - Generates phrased search results rather than individual word search results. Defaults value is false.
    'exact' => true //(bool) - flag to make it only match whole titles/posts - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
    'sentance' => true //(bool) - flag to make it do a phrase search - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters
  10. @luetkemj luetkemj renamed this gist Apr 30, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. @luetkemj luetkemj renamed this gist Apr 30, 2012. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -161,7 +161,10 @@ $args = array(
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Search Parameter
    's' => $s //(string) Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    's' => $s, //(string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    'compare' => '=', //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    'sentance' => true //(bool) - Generates phrased search results rather than individual word search results. Defaults value is false.

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

  12. @luetkemj luetkemj renamed this gist Apr 16, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @luetkemj luetkemj renamed this gist Apr 16, 2012. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -67,20 +67,24 @@ $args = array(
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    'my-post-type', // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'auto-draft', // - a newly created post, with no content.
    'future', // - a post to publish in the future.
    'private', // - not visible to users who are not logged in.
    'inherit', // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
    'post_type' => 'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'post_status' => 'any', // - retrieves any status except those from post types with 'exclude_from_search' set to true.



    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
  14. @luetkemj luetkemj revised this gist Mar 28, 2012. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -178,10 +178,4 @@ endif;
    // Reset Post Data
    wp_reset_postdata();

    ?>





    http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    ?>
  15. @luetkemj luetkemj revised this gist Mar 28, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -157,7 +157,7 @@ $args = array(
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Search Parameter
    's' => $s //(string) Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    's' => $s //(string) Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

  16. @luetkemj luetkemj renamed this gist Mar 28, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  17. @luetkemj luetkemj renamed this gist Mar 28, 2012. 1 changed file with 11 additions and 3 deletions.
    14 changes: 11 additions & 3 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -149,13 +149,15 @@ $args = array(
    //////Permission Parameters - Display published posts, as well as private posts, if the user has the appropriate capability:
    'perm' => 'readable' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilitiealthough I have not tested)

    ////Parameters relating to caching
    //////Parameters relating to caching
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order timplement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not tcount the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more informatiosee: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true //(bool) Default is true
    'update_post_meta_cache' => true, //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Search Parameter
    's' => $s //(string) Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    @@ -176,4 +178,10 @@ endif;
    // Reset Post Data
    wp_reset_postdata();

    ?>
    ?>





    http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
  18. @luetkemj luetkemj revised this gist Mar 21, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -26,8 +26,8 @@ $args = array(
    'tag__and' => array( 2, 6), //(array) - use tag ids.
    'tag__in' => array( 2, 6), //(array) - use tag ids.
    'tag__not_in' => array( 2, 6), //(array) - use tag ids.
    'tag_slug__and' => array( 2, 6), //(array) - use tag slugs.
    'tag_slug__in' => array( 2, 6), //(array) - use tag slugs.
    'tag_slug__and' => array( 'red', 'blue'), //(array) - use tag slugs.
    'tag_slug__in' => array( 'red', 'blue'), //(array) - use tag slugs.

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
  19. @luetkemj luetkemj renamed this gist Mar 15, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  20. @luetkemj luetkemj revised this gist Mar 15, 2012. 2 changed files with 179 additions and 178 deletions.
    179 changes: 179 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,179 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated ba slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you dget_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaultto 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the EdiPage Attributes box) and for Attachments (the integer fields in the Insert / Upload MediGallery dialog), but could be used for any post type with distinct 'menu_order' values (theall default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note alsthat the sorting will be alphabetical which is fine for strings (i.e. words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also notthat a 'meta_key=keyname' must also be present in the query. This value allows for numericasorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => false, //(bool) - ignore sticky posts or not. Default value is false, don't ignore. Ignore/excludsticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order othat list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or ='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilitiealthough I have not tested)

    ////Parameters relating to caching
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order timplement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not tcount the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more informatiosee: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
    178 changes: 0 additions & 178 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,178 +0,0 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated by a slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=>-1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. To reimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts and posts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when using the "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => false, //(bool) - ignore sticky posts or not. Default value is false, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
  21. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  22. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@
    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3,//(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj',//(string) - use 'user_nicename' (NOT name)
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    @@ -38,7 +38,7 @@ $args = array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    array(
    @@ -57,7 +57,7 @@ $args = array(
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated by a slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), // (array) - use post ids. Specify post NOT to retrieve.
    'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    @@ -113,7 +113,7 @@ $args = array(


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => 0, //(bool) - ignore sticky posts or not. Default value is 0, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    'ignore_sticky_posts' => false, //(bool) - ignore sticky posts or not. Default value is false, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    @@ -149,7 +149,7 @@ $args = array(
    'perm' => 'readable' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'no_found_rows' => 0, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true //(bool) Default is true
  23. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  24. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions gistfile1.aw → gistfile1
    Original file line number Diff line number Diff line change
    @@ -149,10 +149,11 @@ $args = array(
    'perm' => 'readable' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'cache_results' => true, //(bool) Deafult is true
    'update_post_term_cache' => true, //(bool) Deafult is true
    'update_post_meta_cache' => true //(bool) Deafult is true
    //NOTE These are not likely to ever be used. Caching is a good thing. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters
    'no_found_rows' => 0, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
    'cache_results' => true, //(bool) Default is true
    'update_post_term_cache' => true, //(bool) Default is true
    'update_post_meta_cache' => true //(bool) Default is true
    //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters
  25. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  26. @luetkemj luetkemj revised this gist Mar 13, 2012. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -118,26 +118,26 @@ $args = array(


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    array(
    'key' => 'price',
  27. @luetkemj luetkemj revised this gist Mar 13, 2012. 2 changed files with 177 additions and 177 deletions.
    177 changes: 177 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,177 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3,//(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj',//(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5,//(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'color', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated by a slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), // (array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=>-1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. To reimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts and posts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when using the "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => 0, //(bool) - ignore sticky posts or not. Default value is 0, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'cache_results' => true, //(bool) Deafult is true
    'update_post_term_cache' => true, //(bool) Deafult is true
    'update_post_meta_cache' => true //(bool) Deafult is true
    //NOTE These are not likely to ever be used. Caching is a good thing. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
    177 changes: 0 additions & 177 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,177 +0,0 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5, //(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'movie_janner', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'action', 'comedy' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated by a slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), // (array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=>-1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. To reimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts and posts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when using the "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => 0, //(bool) - ignore sticky posts or not. Default value is 0, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'cache_results' => true, //(bool) Deafult is true
    'update_post_term_cache' => true, //(bool) Deafult is true
    'update_post_meta_cache' => true //(bool) Deafult is true
    //NOTE These are not likely to ever be used. Caching is a good thing. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>
  28. @luetkemj luetkemj renamed this gist Mar 13, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  29. @luetkemj luetkemj revised this gist Mar 12, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj - luetkemj.com
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
  30. @luetkemj luetkemj created this gist Mar 12, 2012.
    176 changes: 176 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,176 @@
    <?php
    /**
    * WordPress Query Comprehensive Reference
    *
    * CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
    * Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */

    $args = array(

    //////Author Parameters - Show posts associated with certain author.
    'author' => 1,2,3, //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
    'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)

    //////Category Parameters - Show posts associated with certain categories.
    'cat' => 5, //(int) - use category id.
    'category_name' => 'staff', 'news', //(string) - use category slug (NOT name).
    'category__and' => array( 2, 6 ), //(array) - use category id.
    'category__in' => array( 2, 6 ), //(array) - use category id.
    'category__not_in' => array( 2, 6 ), //(array) - use category id.

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

    //////Taxonomy Parameters - Show posts associated with certain taxonomy.
    //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
    //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
    'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
    array(
    'taxonomy' => 'movie_janner', //(string) - Taxonomy.
    'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
    'terms' => array( 'action', 'comedy' ), //(int/string/array) - Taxonomy term(s).
    'include_children' => true, //(boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
    'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
    ),
    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, //(int) - use post id.
    'name' => 'hello-world', //(string) - use post slug.
    'page_id' => 1, //(int) - use page id.
    'pagename' => 'sample-page', //(string) - use page slug.
    'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated by a slash
    'post_parent' => 1, //(int) - use page id. Return just the child Pages.
    'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve.
    'post__not_in' => array(1,2,3), // (array) - use post ids. Specify post NOT to retrieve.
    //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

    //////Type & Status Parameters - Show posts associated with certain type or status.
    'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
    'my-post-type' // - Custom Post Types (e.g. movies)
    ),
    'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
    'publish', // - a published post or page.
    'pending', // - post is pending review.
    'draft', // - a post in draft status.
    'auto-draft' // - a newly created post, with no content.
    'future' // - a post to publish in the future.
    'private' // - not visible to users who are not logged in.
    'inherit' // - a revision. see get_children.
    'trash' // - post is in trashbin (available with Version 2.9).
    'any' // - retrieves any status except those from post types with 'exclude_from_search' set to true.
    ),

    //////Pagination Parameters
    'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=>-1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. To reimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts and posts_per_page on pages where is_archive() or is_search() would be true
    'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('page'), //(int) - number of page. Show the posts that would normally show up just on page X when using the "Older Entries" link.
    //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since Wordpress 3.0.2, you do get_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.

    //////Offset Parameter
    'offset' => 3, //(int) - number of post to displace or pass over.

    //////Order & Orderby Parameters - Sort retrieved posts.
    'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
    //Possible Values:
    //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
    //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'.
    //Possible Values://
    //'none' - No order (available with Version 2.8).
    //'ID' - Order by post id. Note the captialization.
    //'author' - Order by author.
    //'title' - Order by title.
    //'date' - Order by date.
    //'modified' - Order by last modified date.
    //'parent' - Order by post/page parent id.
    //'rand' - Random order.
    //'comment_count' - Order by number of comments (available with Version 2.9).
    //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
    //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
    //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.


    //////Sticky Post Parameters - Show Sticky Posts or ignore them.
    'ignore_sticky_posts' => 0, //(bool) - ignore sticky posts or not. Default value is 0, don't ignore. Ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
    //NOTE: For more info on sticky post queries see: http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters


    //////Time Parameters - Show posts associated with a certain time period.
    'year' => 2012, //(int) - 4 digit year (e.g. 2011).
    'monthnum' => 3, //(int) - Month number (from 1 to 12).
    'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the "start_of_week" option.
    'day' => 17, //(int) - Day of the month (from 1 to 31).
    'hour' => 13, //(int) - Hour (from 0 to 23).
    'minute' => 19, //(int) - Minute (from 0 to 60).
    'second' => 30, //(int) - Second (0 to 60).


    //////Custom Field Parameters - Show posts associated with a certain custom field.
    'meta_key' => 'key', //(string) - Custom field key.
    'meta_value' => 'value', //(string) - Custom field value.
    'meta_value_num' => 10, //(number) - Custom field value.
    'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.
    'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
    array(
    'key' => 'color', //(string) - Custom field key.
    'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
    'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
    'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
    ),
    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' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilities although I have not tested)

    //////Parameters relating to caching
    'cache_results' => true, //(bool) Deafult is true
    'update_post_term_cache' => true, //(bool) Deafult is true
    'update_post_meta_cache' => true //(bool) Deafult is true
    //NOTE These are not likely to ever be used. Caching is a good thing. For more info on usage see: http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters

    //////Post Field Parameters
    //Not sure what these do. For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters

    //////Filters
    //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#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();

    ?>