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.
- post_type – Specifies the post type to retrieve.
- post_id – Specifies a single post ID to retrieve.
- posts_per_page – The number of posts to retrieve.
- offset – The number of posts to offset.
- paged – The page number to retrieve.
- cat – The category ID(s) to retrieve posts from.
- category_name – The category name(s) to retrieve posts from.
- tag – The tag name(s) to retrieve posts from.
- tag_id – The tag ID(s) to retrieve posts from.
- tag__and – The tag ID(s) to retrieve posts that are tagged with all of the specified tags.
- tag__in – The tag ID(s) to retrieve posts that are tagged with one or more of the specified tags.
- tag__not_in – The tag ID(s) to exclude from the results.
- tag_slug__and – The tag slug(s) to retrieve posts that are tagged with all of the specified tags.
- tag_slug__in – The tag slug(s) to retrieve posts that are tagged with one or more of the specified tags.
- tax_query – An array of taxonomy queries to use.
- meta_query – An array of custom field queries to use.
- s – The search string to use.
- search_columns – The columns to search in.
- exact – Whether to search for exact phrases.
- sentence – Whether to search for complete sentences.
- fuzzy – Whether to use fuzzy matching.
- order – The order in which to retrieve the posts.
- orderby – The field to order the posts by.
- orderby_meta_key – The custom field key to order the posts by.
- post__in – An array of post IDs to retrieve.
- post__not_in – An array of post IDs to exclude from the results.
- post_parent – The post parent ID to retrieve.
- post_status – The post status to retrieve.
- post_status__in – An array of post statuses to retrieve.
- post_status__not_in – An array of post statuses to exclude from the results.
- author__in – An array of author IDs to retrieve.
- author__not_in – An array of author IDs to exclude from the results.
- author_name – The author’s login name to retrieve.
- year – The year to retrieve posts from.
- monthnum – The month number to retrieve posts from.
- w – The week number to retrieve posts from.
- day – The day of the month to retrieve posts from.
- hour – The hour to retrieve posts from.
- minute – The minute to retrieve posts from.
- second – The second to retrieve posts from.
- m – The year and month number to retrieve posts from.
- date_query – An array of date queries to use.
- ignore_sticky_posts – Whether to ignore sticky posts.
- suppress_filters – Whether to suppress filters that would alter the query results.
- cache_results – Whether to cache the query results.
- update_post_term_cache – Whether to update the post term cache.
- update_post_meta_cache – Whether to update the post meta cache.
- no_found_rows – Whether to skip counting the total number of rows found.
- perm – The permission to retrieve posts with.
- fields – The fields to retrieve from the posts.
- post__and – An array of post IDs to retrieve, but only posts that are related to all of the specified IDs.
- post__or – An array of post IDs to retrieve, but only posts that are related to any of the specified IDs.
- meta_key – The custom field key to retrieve.
- meta_value – The custom field value to retrieve.
- meta_value_num – The numeric custom field value to retrieve.
- meta_compare – The comparison operator to use when comparing custom field values.
- meta_type – The type of the custom field to retrieve.
- post_mime_type – The mime type of the post to retrieve.
- has_password – Whether the post has a password.
- post_password – The password for the post.
- comment_count – The number of comments to retrieve.
- comment_status – The comment status to retrieve.
- include – An array of post IDs to include in the results.
- exclude – An array of post IDs to exclude from the results.
- post_format – The post format to retrieve.
- date_query – An array of date queries to use.
- name – The post name to retrieve.
- feed – Whether to retrieve the posts for a feed.