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. Supported are (according to superficial testing and the documentation):
|author||author ID or comma-separated list of IDs|
|author_name||uses user_nicename (Try the last piece of the URL of the author’s page.)|
|cat||ID or comma-separated list of IDs of categories1; prepend a “-” to a number to exclude this category.|
|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.
|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”.2
|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|
|include||comma-separated list of post3 IDs|
|exclude||comma-separated list of post3 IDs|
|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).4|
|monthnum||month as number 1-12|
|post_type||Default is “post”. Needs to be set if you want to redirect to anything else, like “product“.|
Note for custom post types: Requires has_archive in the definition of that post type.
|s||search for a keyword|
|w||week of the year|
|has_password||1 for posts with passwords; 0 for posts without passwords|
|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+)|
Redirect to a random post from the past month:
Find many more examples on the example page.
- For custom taxonomies use custom_taxonomy_slug and custom_taxonomy_term
- Write spaces as “%20”. Pay attention to key words like “year”, which are in singular.
- or page, with parameter “custom_type=page”
- Please note that we decided to reverse the default WordPress behavior in order to provide the functionality that most users would expect.