Return to the main plugin page.
This plugin works invisibly in the background. When it is active, all URLs that contain certain keywords redirect to a post that is determined by these parameters. The result depends on the available posts at the time when the redirect happens. For example, the oldest post of the past month can be different today and tomorrow.
You can use the resulting URL as a link, in a menu or a button, or you can even send it around in a newsletter.
Add the query parameter redirect_to to the URL of your blog. This parameter is mandatory.
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.
Redirect to the latest post:
Redirect to the post with the highest number of comments:
(Note: Replace everywhere “www.example.com” with your blog’s URL.)
You can combine these actions with other search parameters in order to limit the 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 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|
Redirect to a random post from the past month:
If Nothing Was Found
You can also add a parameter default_redirect_to where you can specify a default destination if the other criteria return 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 the redirects in your statistics. Supported are Google Analytics (utm_source, utm_campaign and utm_medium) and
Piwik Matomo (pk_campaign and pk_kwd).
Redirect to the latest post that uses the tag with the ID 23 and add the campaign identifier “my_link” . If no post uses that tag, go to the post or page with the ID 12.
Shortcode to Create a Button
You can create a button in a page or text widget with a simple shortcode:
Possible parameters are:
div_class: Class name used for the enclosing div.
button_class: Class name used for the button.
text: Button text. Put the text into quotes if it contains spaces. Default: “Random Post”
redirect_to: Sets the query parameter, see the explanations above. Default: “random”
params: Additional parameters. Formatted as: “key1=>value1,key2=>value2, …”
[redirect_to_post_button text="Go to latest post about XY" redirect_to="latest" params="tag_id=>23"]
You can, of course, also create your own button, link or menu and just manually insert the URL.
FAQs and Troubleshooting
Please continue to this page.