Skip to main content
SEO

WordPress 7.2 turns on a /random/ post redirect by default

WordPress 7.2 is scheduled for release on 8 December and will add a /random/ address to every site that installs it, switched on by default. A visit to example.com/random/ sends the visitor to a randomly chosen published post. There is no setting in the dashboard to turn it off. The off switch is a filter, which a developer can add in code or a plugin can set.

The first release candidate shipped on 17 November with what WordPress described as improvements to the random-content redirect, and its list of release highlights includes random post discovery. The 7.2 Field Guide for developers followed on 20 November. Any site that updates on release day gets the feature with it, so the decision about whether to keep it needs to happen before then.

Audit which post types default to randomable

The dev note of 5 November, written by Aaron Jorbin, explains that the random base is prefixed to the existing archive paths. With pretty permalinks and the default base, /random/ picks from all posts, /random/category/release/ picks a post from one category, /random/tag/dev-note/ from one tag and /random/author/jorbin/ from one author. A custom post type gets /random/{post-type-slug}/.

Eligibility comes from a new randomable argument on register_post_type(). When a developer does not set it, it defaults to true for any post type that is publicly queryable and has an archive. Among the built-in types, posts qualify; pages and attachments do not. The redirect picks only published posts, and the development code skips password-protected ones.

Site owners can rename the base word in a new field under Settings > Permalinks, and the word itself can be translated. The code also responds to a ?random query variable on the home page and archives, and since a change on 16 November a search URL carrying that parameter redirects to the same search without it.

The dev note treats switching it off as the exception: anyone with "a legitimate reason to not support this on a site, or you simply hate fun" can use the filter, it says.

Business sites expose testimonials through /random/

The catch for business sites is the custom post types that a theme or plugin registered years ago with public access and an archive, because that was the easy way to make them work. Testimonials, case studies, events and staff profiles can be set up that way, even when none of them appear in the site's navigation. Commenters on the dev note named testimonials and client information as examples of custom post types that are public by URL but never meant to be browsed.

Joost de Valk wrote in the comments: "This is a horrible idea to turn on by default." In a later reply he said he feared people would end up on invoices, offers and client-specific pages. Jorbin answered another commenter by citing the WordPress Philosophies, arguing that WordPress does not add a switch for every feature because the settings screens would become unmanageable.

Nothing in the dev note says the selection skips posts an SEO plugin has marked noindex, and a commenter's question on that point was still unanswered on 16 November. If a post is published, has no password and its post type qualifies, a /random/ URL can land on it: /random/ itself for blog posts, /random/{post-type-slug}/ for a custom post type.

Is the post behind a /random/ redirect noindexed?

The redirect is a 302. The development code sends no-cache headers and an X-Robots-Tag: noindex, follow header with that 302 response. The header covers the /random/ request itself and nothing else; the post the visitor lands on is served as normal, with whatever robots directives it already had. That is the same X-Robots-Tag noindex mechanism Google recommended when it told platforms to noindex shared and generated pages, and in both cases it binds only to the response that carries it. If no post matches, the request returns a 404.

Use the dev note's spelling of wp_enable_random_content_redirect

The dev note gives the off switch as a one-line must-use plugin: add_filter( 'wp_enable_random_content_redirect', '__return_false' );. With that in place WordPress generates no random rewrite rules, hides the base field on the Permalinks screen and ignores the random query variable. The code's own documentation says rewrite rules need flushing after the filter value changes. A No Random Posts plugin in the WordPress.org directory sets the same filter for site owners who would rather not touch code.

The "What's new for developers" roundup WordPress published on 13 November names the filter as wp_enable_random_content_direct, which does not match the name in the dev note. A developer who copies the roundup's version gets a filter that does nothing and a /random/ path that still works. The same roundup described the Secrets API as landing in 7.2; WordPress removed that API from the release on 17 November to let it mature for a later version. Take the filter name from the dev note.

The Field Guide, published during the release candidate phase, lists 21 new hooks in 7.2 (16 filters and 5 actions) across more than 440 Core Trac tickets. It is the document for breaking changes: the admin menu and admin bar switch from Dashicons font glyphs to inline SVG icons, so plugin CSS that styles those icons through ::before may need updating, and client-side media processing extends to the Media Library grid.

An existing random page stops the redirect

If a site already has a published page with the slug "random", that page wins and the redirect does not fire. A post with that slug does the same on sites whose permalinks use the post name. Peter Wilson confirmed the clash in the dev note's comment thread and proposed a different base, such as "shuffle". Matt Mullenweg, who leads the release, replied to a commenter with an existing random page: "I agree it should not use page URL structure." By 17 November the feature's maintainers had changed neither the default nor the URL pattern.

Page caches can hold the /random/ 404

WordPress's hosting team found that /random/ returns a 404 after an upgrade until the rewrite rules are rebuilt, which core does on the first wp-admin request (once per site on multisite). That applies to every upgraded site, not only cached ones. Behind a page cache or CDN, the cached 404 stayed in their test until the cache was purged, so the team recommends running wp rewrite flush on every site after each upgrade and then purging the cache. A tester who upgraded from the Dashboard on a shared host with no page cache saw the redirect working straight away, but that upgrade was itself a wp-admin request; a site that updates in the background may not make one until someone logs in.

Load was the other objection. Ryan McCue raised the cost of a randomly ordered query on large sites, especially with bots hitting /random/ repeatedly. A fix landed on 17 November that looks up random post IDs instead of sorting the whole archive, which the commit says "keeps the cost of a request independent of the number of posts". Where an archive's posts are thinly spread across the ID range, WordPress draws instead from a stored, shuffled list capped at 1,000 posts. Generating that list means reading all eligible posts, though sites with a persistent object cache keep it for 10 minutes. Mullenweg's response was that searches, query strings and the REST API already give anyone many more ways to overload a site.

The /random/ check comes before the update

Mojo Dojo moved to the Hatamoto CMS this month, so this release misses our own site. For a business site that stays on WordPress, the pre-update check looks like this:

  • List every registered post type that is publicly queryable and has an archive. Testimonials, case studies, events and staff profiles are the usual suspects.
  • For each one that should stay out of /random/, have your developer add 'randomable' => false to its registration.
  • To remove the feature entirely, add a must-use plugin with add_filter( 'wp_enable_random_content_redirect', '__return_false' ); and flush the rewrite rules. Spell it as the dev note does.
  • Check for an existing page or post with the slug random. If one exists and you keep the feature, change the base on the Permalinks screen.
  • If you keep the feature, visit wp-admin once after the update (or run wp rewrite flush on each site), then purge any page cache.
  • Compare any SEO plugin noindex rules against the eligible post types, since the selection does not skip noindexed posts.

If the update means a short outage, Google's advice for PHP sites taken offline to patch applies here too: return a 503 for the duration.

Filed under
wordpress 7.2 random redirectwordpress /random/ urldisable wordpress random redirectwp_enable_random_content_redirectwordpress 7.2 seowordpress 7.2 release date