WP Manifestindependent plugin directory
manifest / utilities / random-kill

Random Kill

WordPress plugin: says whether the WordPress 7.2 /random/ content redirect is on, and turns it off. One checkbox.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/robertmonroe/random-kill/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A WordPress plugin that turns off the /random/ content redirect introduced in WordPress 7.2.

What this is for

WordPress 7.2 adds a /random/ endpoint. A visitor who requests it is redirected to a randomly chosen published post. Variants exist for categories, tags, authors and custom post types, for example /random/category/news/.

It is enabled by default, and core ships no setting for it — turning it off otherwise means editing PHP. This plugin puts the check and the switch in the dashboard.

What it does

Adds Settings → Random Kill, which shows one of three states:

  • The /random/ endpoint is ON
  • The /random/ endpoint is OFF
  • Not on this site yet — on WordPress 7.1 and earlier, where the endpoint does not exist

…and one checkbox: Turn off the /random/ endpoint.

That is the whole plugin. One file, no settings beyond the checkbox, no options pages, no dashboard widgets.

Installation

Download random-kill.php, zip it inside a folder named random-kill, and upload it through Plugins → Add New → Upload Plugin. Or drop the folder straight into wp-content/plugins/.

Safe to install before 7.2. It detects that the endpoint is absent, says so, and your choice applies the moment you upgrade.

How it works

Ticking the box applies core's own filter:

add_filter( 'wp_enable_random_content_redirect', '__return_false' );

It is applied at priority 99, so anything hooked at 100 or above can still override it.

Per the core dev note, this removes the random rewrite rules, makes the random query variable do nothing, and takes the random base field off the Permalinks screen.

The plugin also clears the cached rewrite_rules option when the setting changes, so WordPress rebuilds the rules on the next request. It deliberately does not call flush_rewrite_rules() at that moment: by the time the option is written, init has already run under the previous setting, so flushing there would cache the rules you just replaced.

Two things that will confuse you

A page cache will serve the stale response. On LiteSpeed, and most likely on any full-page cache, the old 404 or 302 keeps being served after you toggle the setting. Purge the cache before you conclude anything. This produced three false negatives while testing.

/random/ needs a non-empty Random base. The pretty URL only gets a rewrite rule when wp_random_base has a value. If you switch the endpoint off and later back on and /random/ still returns 404 while ?random=1 correctly returns 302, go to Settings → Permalinks, put random in the Random base field and save. The plugin's settings page says this too.

Verified behaviour

Tested against WordPress 7.2-beta5 with anonymous external requests, cache purged before each read:

/random/ ?random=1
Unticked (core default) 302 to a published post 302
Ticked 404 200

Ordinary URLs were unaffected in both states. Also verified that the Random base field disappears from Settings → Permalinks while the endpoint is off.

Activation was additionally checked on WordPress 7.1.4, where the plugin reports Not on this site yet and adds no filters.

Notes

  • On multisite the setting is per site.
  • Deleting the plugin removes its single option.
  • Requires PHP 7.4+.

Licence

GPL-2.0-or-later.