You can combine the target parameters with filter parameters in order to narrow down the scope of considered posts to a certain subsample. Time parameters refer to the time of publishing. Wherever WordPress requires an array((Search the parameter on the linked page and check if “(array)” is written behind it.)), you submit the items as comma-separated list. Supported are (according to superficial testing and the documentation):
author | author ID or comma-separated list of IDs; see WordPress documentation |
author_name | uses user_nicename (Try the last piece of the URL of the author’s page.); see WordPress documentation |
author__in | see WordPress documentation |
author__not_in | see WordPress documentation |
cat | ID or comma-separated list of IDs of categories((For custom taxonomies use custom_taxonomy_slug and custom_taxonomy_term)); prepend a “-” to a number to exclude this category.; see WordPress documentation |
category_name | category slug((For custom taxonomies use custom_taxonomy_slug and custom_taxonomy_term)); see WordPress documentation |
category__and | see WordPress documentation |
category__in | see WordPress documentation |
category__not_in | see WordPress documentation |
custom_taxonomy_slug, custom_taxonomy_field, custom_taxonomy_term | Filter by a custom taxonomy. You need to use at least “custom_taxonomy_slug” and “custom_taxonomy_term”. “custom_taxonomy_slug” is the identifier of that taxonomy, such as “product_tag” or “product_cat”, while “custom_taxonomy_term” is the specific tag or category you are searching. “custom_taxonomy_field” tell how to identify the tag or category. Default is “slug” (“tshirts”, “special-product”, …). Allowed values are “term_id”, “name”, “slug” and “term_taxonomy_id”. You can also use a comma-separated list of terms. |
before (or date_query_before) | Only posts from before the specified time will be considered. The value can be anything that can be understood by strtotime(), including relative formats like “last monday” or “1 year ago”.((Write spaces as “%20”. Pay attention to key words like “year”, which are in singular.)) |
after (or date_query_after) | See before. This one restricts the choice of posts to those after the specified time. You can combine both parameters. |
day | day of the month; see WordPress documentation |
include | comma-separated list of post((or page, with parameter “custom_type=page”)) IDs |
exclude | comma-separated list of post((or page, with parameter “custom_type=page”)) IDs |
hour | see WordPress documentation |
ignore_sticky_posts | Set to 0 if you want to consider the stickiness of posts and sort sticky posts to the front. By default sticky posts are treated as normal posts (ignore_sticky_posts=1).((Please note that we decided to reverse the default WordPress behavior in order to provide the functionality that most users would expect.)) WordPress puts sticky posts to the beginning even when searching for oldest posts. Since we need to retrieve post objects when ignore_sticky_posts=0, you may run into PHP memory problems if you have many or huge posts and try to pick a random. |
meta_key | The key (name) of a custom field. see WordPress documentation |
meta_value | The value of a custom field. see WordPress documentation |
meta_value_num | The numeric value of a custom field. see WordPress documentation |
meta_compare | The operator to compare a custom field. see WordPress documentation |
minute | see WordPress documentation |
monthnum | month as number 1-12; see WordPress documentation |
post_type | Default is “post”. Needs to be set if you want to redirect to anything else, like “product” or “page”. This can be a comma-separated list. Note for custom post types: Requires has_archive in the definition of that post type. |
post__in | see WordPress documentation |
post__not_in | see WordPress documentation |
post_name__in | see WordPress documentation |
post_parent | see WordPress documentation |
post_parent__in | see WordPress documentation |
post_parent__not_in | see WordPress documentation |
s | search for a keyword; see WordPress documentation |
second | see WordPress documentation |
tag | tag slug((For custom taxonomies use custom_taxonomy_slug and custom_taxonomy_term)) |
w | week of the year; see WordPress documentation |
has_password | 1 for posts with passwords; 0 for posts without passwords |
tag_id | tag ID |
tag__and | see WordPress documentation |
tag__in | see WordPress documentation |
tag__not_in | see WordPress documentation |
tag_slug__and | see WordPress documentation |
tag_slug__in | see WordPress documentation |
comment_count | Filter by the number of comments. Negative values search for posts that have not that number of comments (!=). (requires WP 4.9+) |
comment_count_min | Filter by a minimum number of comments (>=). (requires WP 4.9+) |
comment_count_max | Filter by a maximum number of comments (<=). (requires WP 4.9+) |
Example
Redirect to a random post from the past month:
http://www.example.com/?redirect_to=random&after=1%20month%20ago
Find many more examples on the example page.