Note: This plugin is provided for free. Particularly if you use it to make money or in a profit-making context, however, I would appreciate if you could make a donation. Thank you!
Return to the main plugin page.
Add the query parameter redirect_to to the URL of your blog. Values can be:
- last or latest – The URL will redirect1 to the latest post.
- first or oldest – The URL will redirect to the first (oldest) post.
- random – The URL will redirect to a random post.
- custom – The post will be determined according to the mandatory parameter orderby and the optional parameter order. Possible values for orderby are listed here. By default, order is “DESC” (descending – starting from the highest value, the later time or the bottom position in alphabetic order). Alternatively you can set it to “ASC” (ascending).
Obviously, the parameter “custom” lets you achieve the same as “latest”, “first” and “random”. These shortcuts exist just for convenience and readability.
You can combine these actions with other search parameters in order to limit the considered posts to a certain group. 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 categories; prepend a “-” to a number to exclude this category.|
|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”.2
|date_query_after||See date_query_before. This one restricts the choice of posts to those after the specified time. You can combine both parameters.|
|day||day of the month|
|exclude||comma-separated list of post or page IDs|
|monthnum||month as number 1-12|
|post_type||note: requires has_archive for that post_type; default is post|
|s||search for a keyword|
|w||week of the year|
|has_password||1 for posts with passwords; 0 for posts without passwords|
You can also add a parameter default_redirect_to where you can specify a default destination if the other criteria returns an empty result. It accepts as value the id of a post or page. If this parameter is omitted or if the post or page with this id cannot be found, then the default destination is the home page.
Since version 0.5, you can also add parameters for tracking redirects in your statistics. Supported are Google Analytics (utm_source, utm_campaign and utm_medium) and Piwik (pk_campaign and pk_kwd).
Since Version 0.5, you can create a button with a shortcode. The syntax3 is:
Possible parameters are:
div_class: Class name used for the enclosing div.
button_class: Class name used for the button.
text: Button text. Default: “Random Post”
redirect_to: Sets the query parameter. Default: “random”
params: Additional parameters. Formatted as: “key1=>value1,key2=>value2, …”
[redirect_to_random_button text="Go to latest post" redirect_to="latest" params="tag_id=>23"]
You can, of course, create your own button, link or menu and just manually insert the URL.