free web page counters

Fix Yoast SEO’s ai-optimize Bug Before It Ruins Your Site’s SEO

Sedang Trending 1 bulan yang lalu

A friend reached retired to maine precocious aft discovering thing alarming successful their WordPress posts. They were utilizing Yoast SEO Premium pinch nan Classic Editor, and they recovered Yoast had been automatically inserting odd-looking CSS classes for illustration ai-optimize-6, ai-optimize-9, straight into their content.

The problem is that these classes stay permanently embedded successful nan posts moreover aft disabling Yoast AI Optimize aliases wholly deleting nan plugin. This goes against expected plugin behavior… that is, erstwhile you uninstall it, it should time off nary trace successful your content.

While these AI markers mightiness not visually impact your site, they clutter up your root code. It could besides perchance awesome to AI contented detectors, plagiarism checkers, and moreover hunt engines that your contented was AI-generated aliases optimized.

In this guide, I’ll show you really to region these hidden classes utilizing a speedy codification snippet. I’ll besides explicate really to use it safely and stock nan SEO plugin I urge utilizing arsenic an replacement to Yoast.

Fixing nan ai-optimize bug successful Yoast SEO

Here are nan things I will screen successful this tutorial:

Why These ai-optimize Classes Are Bad for SEO

The ai-optimize-{number} CSS classes are added erstwhile you usage Yoast SEO Premium’s AI features pinch nan Classic Editor. They don’t look connected nan beforehand end, but they’re embedded successful your content’s HTML, which tin origin problems.

You tin position them by visiting immoderate station aliases page connected your tract and using nan Inspect tool successful your browser.

AI optimize bug successful Yoast SEO

Here’s why I urge removing them:

  • They clutter your HTML: These unnecessary classes make your codification harder to publication and parse.
  • They service nary purpose: They don’t impact really your contented looks aliases functions. They’re conscionable leftovers from nan AI tool.
  • They tin trigger AI discovery tools: Some plagiarism checkers and AI contented detectors pick up these patterns and whitethorn emblem your post, moreover if you wrote it yourself.
  • They time off AI footprints crossed your site: If aggregate sites usage nan aforesaid classes, Google mightiness commencement associating that shape pinch low-quality aliases mass-produced AI content.
  • They summation nan consequence of formatting conflicts: Unknown classes could interfere pinch your taxable aliases plugins down nan road.

There’s nary upside to keeping these hidden markers, and respective bully reasons to cleanable them out.

The bully news is that location is simply a speedy fix, and I’ll show you really to do it safely successful nan adjacent section.

Step 1: Make a Backup Before Making Changes

Before we move forward, I ever urge creating a afloat backup of your WordPress site. It only takes a fewer minutes and gives you bid of mind successful lawsuit thing goes wrong.

I usage Duplicator erstwhile I request a speedy and reliable backup solution. It’s nan champion WordPress backup plugin connected nan market, it is beginner-friendly, and it useful awesome whether you’re backing up aliases migrating your site.

  • ✅ On-demand and automatic WordPress backups
  • ✅ Safely stored successful distant locations for illustration Dropbox aliases Google Drive
  • ✅ Easy 1-click reconstruct if thing breaks

For details, spot our guideline connected how to backmost up your WordPress website.

Once your backup is ready, you’re safe to move connected to nan adjacent step, wherever I will show you really to hole nan problem.

Step 2: Add nan Code Snippet to Remove ai-optimize Classes

Now that your backup is ready, it’s clip to cleanable up those ai-optimize-{number} and ai-optimize-introduction classes.

I’ve put together a safe and elastic codification snippet that useful pinch some nan Classic Editor and nan Block Editor (Gutenberg), arsenic good arsenic bulk edits.

You don’t request to touch your taxable files aliases messiness pinch FTP. Instead, I urge utilizing nan WPCode plugin to adhd this snippet. It’s what I usage to negociate codification snippets connected WordPress sites without risking thing important. (See my afloat WPCode review for much details.)

Tip: WPCode has a constricted free version that you tin usage for this tutorial. However, I urge upgrading to a paid scheme to unlock its afloat potential.

If this is your first clip adding civilization codification to your site, past you tin return a look astatine our guideline connected how to adhd civilization codification snippets successful WordPress without breaking your site.

First, you request to instal and activate nan WPCode plugin. See our tutorial connected installing a WordPress plugin if you request help.

Once nan plugin has been activated, spell to nan Code Snippets » + Add Snippet page and click connected ‘+ Add Custom Snippet’ fastener nether nan ‘Add Your Custom Code (New Snippet)’ box.

WPCode adhd civilization codification snippet

Next, you request to supply a title for your codification snippet. This could beryllium thing that helps you place this codification easily.

After that, take PHP Snippet from nan ‘Code Type’ drop-down menu.

Adding Yoasst AI optimize bug fixing code

Now, you request to transcript and paste nan pursuing codification into nan Code Preview box.

Here’s nan afloat codification snippet:

// For Classic Editor and programmatic updates function strip_ai_optimize_classes($data, $postarr) { if (empty($data['post_content']) || $data['post_type'] !== 'post') { return $data; } $data['post_content'] = strip_ai_optimize_from_content($data['post_content']); return $data; } add_filter('wp_insert_post_data', 'strip_ai_optimize_classes', 10, 2); // For Gutenberg/Block Editor function strip_ai_optimize_classes_rest_insert($prepared_post, $request) { if (isset($prepared_post->post_content) && $prepared_post->post_type === 'post') { $prepared_post->post_content = strip_ai_optimize_from_content($prepared_post->post_content); } return $prepared_post; } add_filter('rest_pre_insert_post', 'strip_ai_optimize_classes_rest_insert', 10, 2); // For bulk edit operations - this is nan cardinal addition function strip_ai_optimize_classes_bulk_edit($post_id) { $post = get_post($post_id); if (!$post || empty($post->post_content) || $post->post_type !== 'post') { return; } $cleaned_content = strip_ai_optimize_from_content($post->post_content); if ($cleaned_content !== $post->post_content) { remove_action('post_updated', 'strip_ai_optimize_classes_bulk_edit'); wp_update_post(array( 'ID' => $post_id, 'post_content' => $cleaned_content )); add_action('post_updated', 'strip_ai_optimize_classes_bulk_edit'); } } add_action('post_updated', 'strip_ai_optimize_classes_bulk_edit'); // Catch bulk operations via nan bulk_edit_posts action function strip_ai_optimize_classes_bulk_action($post_ids) { if (!is_array($post_ids)) { return; } foreach ($post_ids arsenic $post_id) { strip_ai_optimize_classes_bulk_edit($post_id); } } add_action('bulk_edit_posts', 'strip_ai_optimize_classes_bulk_action'); // Shared usability to portion ai-optimize classes function strip_ai_optimize_from_content($content) { if (empty($content) || !is_string($content)) { return $content; } return preg_replace_callback( '/class\s*=\s*["\']([^"\']*)["\']/', function($matches) { $classes = $matches[1]; $classes = preg_replace('/\bai-optimize-\d+\b\s*/', '', $classes); $classes = preg_replace('/\s+/', ' ', trim($classes)); if (empty($classes)) { return ''; } return 'class="' . $classes . '"'; }, $content ); }

After adding nan code, scroll down to nan ‘Insertion’ section.

Then, prime ‘Run Everywhere’ adjacent to nan ‘Location’ option.

Run codification snippet everywhere

Finally, spell to nan apical of nan page and move nan position toggle successful nan top-right to Active, and past click connected nan ‘Save Snippet’ fastener to shop your changes.

Once you’ve added this snippet to your tract utilizing WPCode, it will automatically portion these AI-generated classes from immoderate station you create aliases update successful nan future.

If you want to region nan ai-classes from existing content, you’ll person to bulk edit your existing content.

🌟Expert Tip: If you’re not comfortable editing codification yourself, don’t stress!

Our squad astatine WPBeginner offers Emergency WordPress Support Services to thief you hole issues for illustration this quickly and safely. We tin cleanable up your contented and group up your SEO plugin nan correct way.

Step 3: Bulk Update All Posts to Clean Up Existing AI Classes

Now that nan codification snippet is successful place, it will automatically cleanable up immoderate AI markers erstwhile you edit aliases people a post. But to region these classes from your older posts, you’ll request to bulk update them.

Don’t worry—this won’t alteration your content. It simply triggers nan select we conscionable added truthful nan hidden AI classes tin beryllium stripped retired safely.

First, you request to spell to nan Posts » All Posts page successful your WordPress dashboard and click ‘Screen Options’ astatine nan apical right.

Show each posts

From here, group nan number of posts per page to 999 (This is nan maximum number of posts you tin show connected this screen) and click ‘Apply’ to load each your posts.

Next, prime each posts connected nan page by clicking nan apical checkbox. After that, prime ‘Edit’ by clicking connected nan Bulk Actions dropdown, past click ‘Apply’.

Bulk edit posts

WordPress will now show you bulk editing options. Without changing thing else, simply click connected nan ‘Update’ button.

WordPress will now commencement updating each your posts. By doing this, it will besides trigger nan codification you saved earlier and region nan AI classes.

Update each posts

Tip 💡: If you person much than 999 posts, conscionable spell to nan adjacent page and repetition this process until each posts person been updated.

This will cleanable nan ai-optimize-{number} and ai-optimize-introduction classes from each your existing posts—no manual editing needed.

Bonus Tip: Switching to an Alternative SEO Plugin (Better and More Powerful)

Yoast SEO has been astir for a agelong time, but lately, its innovations person slowed down.

At WPBeginner, we made nan determination to move to All successful One SEO crossed each our sites a fewer years ago. It was a large move, and we documented each logic successful this lawsuit study: Why We Switched from Yoast to All successful One SEO.

All successful One SEO website

I now usage All successful One SEO connected each individual task and each customer websites. It’s my go-to SEO plugin because it offers:

  • ✅ Comprehensive features for nan AI hunt era (schema markup, precocious sitemaps, AI integrations, and more)
  • ✅ Easy setup pinch smart defaults and checklists
  • ✅ Better support for section SEO, WooCommerce, Google News, and more.

If you’re still connected nan fence, we’ve made a elaborate side-by-side breakdown here: Yoast SEO vs All successful One SEO – Which Is nan Better Plugin?

Bonus SEO Resources

Whether you’re switching distant from Yoast SEO aliases conscionable want to tighten up your WordPress SEO strategy, present are immoderate adjuvant resources to guideline you.

These tutorials and comparisons tin prevention you time, debar costly mistakes, and thief you get amended results from your SEO efforts:

  • Best Yoast SEO Alternatives For WordPress
  • The Ultimate WordPress SEO Migration Checklist (For Beginners) – Helps you move distant from Yoast to All successful One SEO
  • How to Set Up All successful One SEO for WordPress Correctly (Ultimate Guide)
  • Complete WordPress SEO Guide for Beginners (Step by Step)
  • How to Use AI for SEO successful WordPress (12 Tools)
  • Is AI Content Bad for WordPress SEO? (Expert Insights & Tips)

I dream this guideline helped you hole nan ai-optimize people rumor successful Yoast SEO and group your tract up for amended semipermanent results. You’ve sewage this—and if you ever request a hand, we’re present to help.

If you liked this article, past please subscribe to our YouTube Channel for WordPress video tutorials. You tin besides find america on Twitter and Facebook.

Disclosure: Our contented is reader-supported. This intends if you click connected immoderate of our links, past we whitethorn gain a commission. See how WPBeginner is funded, why it matters, and really you tin support us. Here's our editorial process.