WordPress 7.2 ships a /random/ redirect on Dec. 8, on by default
WordPress 7.2 turns on a /random/ redirect by default with no checkbox to stop it. One filter line disables it site-wide; a post type argument excludes single types.
To fix random redirects in WordPress 7.2, switch off the /random/ endpoint that the release turns on by default. Add this line to your child theme's functions.php or a small site plugin: add_filter( 'wp_enable_random_content_redirect', '__return_false' );. WordPress gives you no checkbox in the dashboard for this, so the filter is the only switch.
Version 7.2 is scheduled for December 8, according to the developer note. Before you update, it's worth knowing what the feature does, which post types it can reach, and why a testimonial you deliberately kept out of search may still turn up.
What /random/ actually does
The endpoint picks a published post, or a custom post type that is publicly queryable and has archives, and forwards the visitor there with a 302. Pages and attachments are excluded from the pool. The redirect response carries an X-Robots-Tag: noindex, follow header; the post the visitor lands on does not get that header added by the feature.
Spelling matters here. The developer note gives the filter name as wp_enable_random_content_redirect. WordPress's November developer news roundup used a different spelling that does not appear anywhere in the code, so copy the version above rather than the one in the roundup.
Turning it off for the whole site
The filter belongs in a child theme's functions.php, an mu-plugin, or a tiny plugin you write yourself. Skip the parent theme: an update replaces that file and your filter leaves with it. An mu-plugin is the safer home for a switch you want to survive theme changes and plugin cleanups.
After you add it, open yoursite.com/random/ in a private window. If the filter is working, the URL stops redirecting. Clear your page cache and your CDN cache first if you run either, because a cached 302 will keep serving the redirect after the code has changed.
Excluding one post type instead of killing the feature
If you want to keep /random/ but keep client testimonials out of it, add 'randomable' => false to the arguments in your register_post_type() call. That's the per-type switch the developer note provides, and it takes that post type out of the rotation while leaving the endpoint live for ordinary posts.
When a plugin or theme owns the post type, edit the arguments at registration with the register_post_type_args filter. Leave a comment next to it, because the next person to read that file will wonder why the argument is there.
Why a noindexed testimonial can still appear at /random/
The endpoint doesn't consult your SEO plugin. Any post type that is publicly queryable and has archives sits in the pool, even when Yoast or Rank Math has set those entries to noindex. That means a page you kept out of search results can still be reached by anyone who hits /random/ a few times.
The page stays out of Google's index through whatever meta robots tag your plugin writes, and the redirect URL itself is noindexed by the header. Neither of those stops a person from reading the content. If a testimonial or case study has details you don't want public, noindex was never the control you needed.
When the cause isn't /random/ at all
Core WordPress before 7.2 has no /random/ endpoint, so if visitors are being bounced around today, something installed on the site is doing it. Start with plugins that manage redirects, then search your theme files for wp_redirect() calls, then look at the host-level rules in .htaccess or the nginx config. A compromised install can inject redirects too, so run a malware scan if the plugin list doesn't explain it.
Search Console's URL inspection tool shows which redirect Google records for a sample URL, and that usually points at the layer doing the work. If you moved to a CDN recently, check that Googlebot still gets through, since a CDN change is a common way to block the crawler without noticing.
Does /random/ hurt search performance?
Barely, on a normal business site. The 302 keeps the redirect temporary, the noindex header keeps the /random/ URL itself out of the index, and Google follows through to the destination, which keeps its own robots settings. The thing that changes is how much of your archive is reachable: on a site with hundreds of posts, the endpoint hands crawlers and visitors a path to entries you never link from anywhere.
Who should leave it on
Sites whose whole point is browsing get a free "surprise me" link out of this. A photo log, a recipe archive with 600 entries, a quotes collection: all of them benefit from a URL that serves something different each time. A five-page service business gets nothing from it and one more URL to reason about. I'd turn it off and revisit if an actual use turns up.
Either way, run the update on staging before December 8 and hit /random/ to see what it serves. Check the post types that meet the eligibility rules while you're there. Testimonials, staff bios and case studies are the ones that surprise people.
Frequently asked questions
- How do I turn off /random/ in WordPress 7.2?
- Add add_filter( 'wp_enable_random_content_redirect', '__return_false' ); to your child theme's functions.php or an mu-plugin. There is no dashboard setting for the feature, so the filter is the only control. It disables the endpoint for the entire site.
- Is the /random/ redirect a 301 or a 302?
- A 302, which browsers and Google treat as temporary. The redirect response also sends an X-Robots-Tag: noindex, follow header, which keeps the /random/ URL itself out of search results while letting the crawler follow through to the post.
- Why can't I find a setting to disable random redirects?
- WordPress 7.2 ships the feature on by default with no admin toggle anywhere in the dashboard. The developer note sends site owners to the wp_enable_random_content_redirect filter instead, which is why nothing shows up under Settings or Reading.
- Does /random/ include pages and attachments?
- No. It picks from published posts and from custom post types that are publicly queryable and have archives. Registering a post type with 'randomable' => false removes it from the pool as well.
- Can /random/ expose posts I've set to noindex?
- It can send visitors to them, because the endpoint ignores your SEO plugin's noindex settings. The pages stay out of Google's index through their own meta tags, but a person hitting /random/ can still land on and read them.
- My site is on an older WordPress version and redirects randomly. What now?
- Core didn't add /random/ until 7.2, so the redirect comes from a plugin, your theme or the server. Check redirect plugins first, then grep theme files for wp_redirect(), then read .htaccess or the nginx config. Scan for malware if none of those explain it.
Sources
