This version of the free WordPress plugin Redirect URL to Post comes with a new feature: Until now, the parameter random always picked one out of the entire pool of posts (that match the search criteria). Now you can pick a random post from a subsample.
The new parameter count lets you limit the pool of posts to the most recent (count has positive number) or oldest (count has negative number) posts.
Here we redirect to a random post among the most recent 20 posts.
The value can also be negative, which means that we count from the opposite side, starting from the oldest posts.
The parameter count can be used together with offset so that you omit some of the posts at the beginning or the end.
Now we omit the oldest 5 posts and pick a random item from the next 10 oldest posts.
- I changed the default duration of the cache to 60 seconds. Many users don’t seem to be aware of the existence of caching, so it made sense to turn it on by default. You can still override it with „cache=0“.
- Random posts are now always determined by PHP, not through the database query. This simplified parts of the code and also shifted the burden from the database to the PHP engine.
Install the plugin from the administration of your site or download it from WordPress.org.
Photo by keepitsurreal