A Comprehensive Guide to WP_Query Arguments for WordPress

A Comprehensive Guide to WP_Query Arguments for WordPress

Welcome to the comprehensive list of WP_Query arguments! WP_Query is a powerful tool in WordPress that allows you to retrieve and display posts and other content from your WordPress database. These arguments allow you to fine-tune your WP_Query and get exactly the content you need. Here is a list of the most commonly used arguments to help you get started.

  1. post_type – Specifies the post type to retrieve.
  2. post_id – Specifies a single post ID to retrieve.
  3. posts_per_page – The number of posts to retrieve.
  4. offset – The number of posts to offset.
  5. paged – The page number to retrieve.
  6. cat – The category ID(s) to retrieve posts from.
  7. category_name – The category name(s) to retrieve posts from.
  8. tag – The tag name(s) to retrieve posts from.
  9. tag_id – The tag ID(s) to retrieve posts from.
  10. tag__and – The tag ID(s) to retrieve posts that are tagged with all of the specified tags.
  11. tag__in – The tag ID(s) to retrieve posts that are tagged with one or more of the specified tags.
  12. tag__not_in – The tag ID(s) to exclude from the results.
  13. tag_slug__and – The tag slug(s) to retrieve posts that are tagged with all of the specified tags.
  14. tag_slug__in – The tag slug(s) to retrieve posts that are tagged with one or more of the specified tags.
  15. tax_query – An array of taxonomy queries to use.
  16. meta_query – An array of custom field queries to use.
  17. s – The search string to use.
  18. search_columns – The columns to search in.
  19. exact – Whether to search for exact phrases.
  20. sentence – Whether to search for complete sentences.
  21. fuzzy – Whether to use fuzzy matching.
  22. order – The order in which to retrieve the posts.
  23. orderby – The field to order the posts by.
  24. orderby_meta_key – The custom field key to order the posts by.
  25. post__in – An array of post IDs to retrieve.
  26. post__not_in – An array of post IDs to exclude from the results.
  27. post_parent – The post parent ID to retrieve.
  28. post_status – The post status to retrieve.
  29. post_status__in – An array of post statuses to retrieve.
  30. post_status__not_in – An array of post statuses to exclude from the results.
  31. author__in – An array of author IDs to retrieve.
  32. author__not_in – An array of author IDs to exclude from the results.
  33. author_name – The author’s login name to retrieve.
  34. year – The year to retrieve posts from.
  35. monthnum – The month number to retrieve posts from.
  36. w – The week number to retrieve posts from.
  37. day – The day of the month to retrieve posts from.
  38. hour – The hour to retrieve posts from.
  39. minute – The minute to retrieve posts from.
  40. second – The second to retrieve posts from.
  41. m – The year and month number to retrieve posts from.
  42. date_query – An array of date queries to use.
  43. ignore_sticky_posts – Whether to ignore sticky posts.
  44. suppress_filters – Whether to suppress filters that would alter the query results.
  45. cache_results – Whether to cache the query results.
  46. update_post_term_cache – Whether to update the post term cache.
  47. update_post_meta_cache – Whether to update the post meta cache.
  48. no_found_rows – Whether to skip counting the total number of rows found.
  49. perm – The permission to retrieve posts with.
  50. fields – The fields to retrieve from the posts.
  51. post__and – An array of post IDs to retrieve, but only posts that are related to all of the specified IDs.
  52. post__or – An array of post IDs to retrieve, but only posts that are related to any of the specified IDs.
  53. meta_key – The custom field key to retrieve.
  54. meta_value – The custom field value to retrieve.
  55. meta_value_num – The numeric custom field value to retrieve.
  56. meta_compare – The comparison operator to use when comparing custom field values.
  57. meta_type – The type of the custom field to retrieve.
  58. post_mime_type – The mime type of the post to retrieve.
  59. has_password – Whether the post has a password.
  60. post_password – The password for the post.
  61. comment_count – The number of comments to retrieve.
  62. comment_status – The comment status to retrieve.
  63. include – An array of post IDs to include in the results.
  64. exclude – An array of post IDs to exclude from the results.
  65. post_format – The post format to retrieve.
  66. date_query – An array of date queries to use.
  67. name – The post name to retrieve.
  68. feed – Whether to retrieve the posts for a feed.