If you need to change the SEO title or meta description from code and an SEO plugin is active, hook the plugin's own filter, not WordPress core. Once Yoast or Rank Math is running, it takes over the document title and prints its own meta description, so the core pre_get_document_title filter you reached for is simply never the last word. Here is the short version:
- Yoast SEO is active: hook
wpseo_titlefor the title andwpseo_metadescfor the description. - Rank Math is active: hook
rank_math/frontend/titleandrank_math/frontend/description. - No SEO plugin (core only): hook
pre_get_document_title(ordocument_title_parts) for the title, and print your own<meta name="description">onwp_head, because core does not emit one.
That is the whole decision. The rest of this page is the code for each path, the per-plugin deep dives (Yoast's canonical, Open Graph and Twitter filters and Rank Math's, plus where each plugin stores the editor's SEO meta), a portable helper that detects which plugin is active and hooks the right filter, the one gotcha that wastes everyone an afternoon (hooking core while a plugin is active and wondering why nothing changes), and, if you are still choosing, Rank Math vs Yoast compared on features, schema, performance, pricing and migration.
Which filter to hook
| Active setup | Title filter | Description filter | Description tag exists by default? |
|---|---|---|---|
| Yoast SEO | wpseo_title | wpseo_metadesc | Yes, Yoast prints it |
| Rank Math | rank_math/frontend/title | rank_math/frontend/description | Yes, Rank Math prints it |
| Core only (no SEO plugin) | pre_get_document_title | (none) | No, you must print it yourself |
The pattern is the same in all three rows: return your value to override, return the value you were given to pass through unchanged. The difference is where the filter lives. Below are the three paths, each one a few lines.
Yoast: wpseo_title and wpseo_metadesc
Yoast generates the title and meta description through its own presentation layer, then exposes them as filters. Hook those and your value wins:
add_filter( 'wpseo_title', 'te_yoast_filter_title' );
function te_yoast_filter_title( $title ) {
if ( ! is_singular( 'product' ) ) {
return $title; // pass through untouched
}
return 'Buy ' . get_the_title() . ' | Acme';
}
add_filter( 'wpseo_metadesc', 'te_yoast_filter_metadesc', 10, 2 );
function te_yoast_filter_metadesc( $description, $presentation ) {
if ( ! is_singular( 'product' ) ) {
return $description;
}
return 'In-stock now: ' . get_the_title() . '. Free returns within 30 days.';
}Two things worth knowing. The wpseo_metadesc filter passes a second argument (the Indexable_Presentation object) since Yoast 14.x, so declare it with add_filter( ..., 10, 2 ) if you want the presentation context; you can ignore it and take one argument if you do not. And both wpseo_title and wpseo_metadesc exist in Yoast SEO free, not just Premium, so you do not need a paid tier to override programmatically.
Override Yoast canonical and social tags
The title and description are only two of the tags Yoast prints. Every frontend tag runs through a named filter, each one expects a string back, and the Yoast Metadata API docs list the full set. The ones you will actually use:
| Filter | Controls | Returns |
|---|---|---|
wpseo_title | <title> text | The page title string |
wpseo_metadesc | <meta name="description"> | The meta description string |
wpseo_canonical | <link rel="canonical"> | The canonical URL |
wpseo_robots | <meta name="robots"> | The robots directive string |
wpseo_opengraph_title | og:title | The Open Graph title |
wpseo_opengraph_desc | og:description | The Open Graph description |
wpseo_opengraph_image | og:image | The Open Graph image URL |
wpseo_twitter_title | twitter:title | The X (Twitter) card title |
wpseo_twitter_description | twitter:description | The X (Twitter) card description |
The social filters do not inherit from wpseo_title and wpseo_metadesc. Override the page title alone and Yoast still builds og:title from its own template, so share previews on Facebook and X drift from the <title> you set. When you change a page's title or description in code, set the matching Open Graph and Twitter filters too.
Most of these callbacks also receive the presentation object as a second argument (its model is the Yoast indexable for the page). Ask for it with the $accepted_args parameter of add_filter:
add_filter( 'wpseo_opengraph_title', function ( $og_title, $presentation ) {
// $presentation->model is the Yoast indexable for this page.
if ( is_singular( 'product' ) ) {
return get_the_title() . ' | Acme Store';
}
return $og_title;
}, 10, 2 );Set canonical, Open Graph and Twitter together
For a rewrite-driven page keyed off a custom query var, override the whole cluster in one place so the tags stay consistent. Reusing one title callback for wpseo_title, wpseo_opengraph_title and wpseo_twitter_title keeps the three in lockstep:
add_action( 'init', function () {
add_filter( 'wpseo_title', 'te_yoast_report_title' );
add_filter( 'wpseo_metadesc', 'te_yoast_report_metadesc' );
add_filter( 'wpseo_canonical', 'te_yoast_report_canonical' );
add_filter( 'wpseo_opengraph_title', 'te_yoast_report_title' );
add_filter( 'wpseo_opengraph_desc', 'te_yoast_report_metadesc' );
add_filter( 'wpseo_twitter_title', 'te_yoast_report_title' );
add_filter( 'wpseo_twitter_description', 'te_yoast_report_metadesc' );
add_filter( 'wpseo_opengraph_image', 'te_yoast_report_image' );
} );
function te_yoast_report_slug() {
$slug = get_query_var( 'report_slug' );
return $slug ? sanitize_title( $slug ) : '';
}
function te_yoast_report_title( $title ) {
$slug = te_yoast_report_slug();
if ( ! $slug ) {
return $title;
}
$name = ucwords( str_replace( '-', ' ', $slug ) );
return sprintf( '%s Report | Acme', $name );
}
function te_yoast_report_metadesc( $description ) {
$slug = te_yoast_report_slug();
if ( ! $slug ) {
return $description;
}
$name = ucwords( str_replace( '-', ' ', $slug ) );
return sprintf( 'Latest %s data, updated daily. Charts, trends, and the raw numbers.', $name );
}
function te_yoast_report_canonical( $canonical ) {
$slug = te_yoast_report_slug();
if ( ! $slug ) {
return $canonical;
}
return home_url( '/reports/' . $slug . '/' );
}
function te_yoast_report_image( $image ) {
$slug = te_yoast_report_slug();
if ( ! $slug ) {
return $image;
}
return home_url( '/reports/' . $slug . '/share.png' );
}The wpseo_canonical override matters most on rewrite-driven pages: without it, Yoast often canonicalizes a virtual URL to something wrong (the front page, or a guessed permalink), and a wrong canonical is worse than none.
Conditional overrides per context
Conditional tags only work after the query is parsed, so the callbacks must run at output time (or be attached on wp or template_redirect). A few patterns I reach for, with the bare return $title; at the end so every page you did not name keeps Yoast's normal output:
add_filter( 'wpseo_title', function ( $title ) {
if ( is_page( 'contact' ) ) {
return 'Contact Acme Support';
}
if ( is_post_type_archive( 'event' ) ) {
return 'Upcoming Events | Acme';
}
if ( is_tax( 'region', 'emea' ) ) {
return 'EMEA Coverage | Acme';
}
if ( get_query_var( 'report_slug' ) ) {
return te_yoast_report_title( $title );
}
return $title;
} );is_page() takes a slug, ID, or title; is_tax() takes a taxonomy and an optional term; is_post_type_archive() takes a post type. If you register the filters inside a must-use plugin, hooking the registration on wp (after the main query is parsed) and skipping it when is_admin() is true keeps the overrides off the admin screens, where the editor should see the values they configured.
Read the editor's Yoast meta instead of replacing it
Sometimes you want to build on what an editor typed into the Yoast meta box rather than throw it away. Yoast stores per-post overrides in ordinary post meta:
| Meta key | Holds |
|---|---|
_yoast_wpseo_title | The SEO title the editor set in the meta box |
_yoast_wpseo_metadesc | The meta description the editor set |
_yoast_wpseo_canonical | A manual canonical override, if set |
add_filter( 'wpseo_metadesc', function ( $description ) {
if ( ! is_singular( 'product' ) ) {
return $description;
}
$stored = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true );
if ( $stored ) {
// Editor wrote one. Append a stock-status note rather than replace it.
$in_stock = get_post_meta( get_the_ID(), '_stock_status', true ) === 'instock';
return $stored . ' ' . ( $in_stock ? 'In stock now.' : 'Currently on backorder.' );
}
return $description;
} );The sharp edge: Yoast templates support %% variables, so the raw meta may be %%title%% %%sep%% %%sitename%%. The string handed to wpseo_title is already expanded; the string from get_post_meta is not. Prefer the filter's value when you want rendered text, and read raw meta only when you need the editor's input. Mixing the two is how %%sep%% ends up visible in someone's <title>.
Rank Math: rank_math/frontend/title and /description
Rank Math uses namespaced filter names. Same shape, different hook:
add_filter( 'rank_math/frontend/title', 'te_rankmath_filter_title' );
function te_rankmath_filter_title( $title ) {
if ( ! is_singular( 'product' ) ) {
return $title;
}
return 'Buy ' . get_the_title() . ' | Acme';
}
add_filter( 'rank_math/frontend/description', 'te_rankmath_filter_description' );
function te_rankmath_filter_description( $description ) {
if ( ! is_singular( 'product' ) ) {
return $description;
}
return 'In-stock now: ' . get_the_title() . '. Free returns within 30 days.';
}Rank Math applies these on the front end as the page builds its head output, so a conditional check (post type, query var, a $_GET flag on a rewrite page) decides per-request whether you override or fall through. Return the incoming $description to leave Rank Math's own value in place.
Override Rank Math canonical and social tags
Rank Math exposes a filter for each piece of metadata it prints. Beyond the title and description, the two you reach for most are the canonical and the Open Graph type:
// The <link rel="canonical"> tag.
add_filter( 'rank_math/frontend/canonical', 'te_rankmath_canonical' );
// The Open Graph type, e.g. "article" or "website".
add_filter( 'rank_math/opengraph/type', 'te_rankmath_og_type' );The Open Graph title and description are network-namespaced. Rank Math builds those filter names as rank_math/opengraph/{network}/{property}, where {network} is facebook or twitter:
add_filter( 'rank_math/opengraph/facebook/og_title', 'te_rankmath_og_title' );
add_filter( 'rank_math/opengraph/facebook/og_description', 'te_rankmath_og_description' );
// Twitter Card equivalents use the twitter namespace.
add_filter( 'rank_math/opengraph/twitter/twitter_title', 'te_rankmath_twitter_title' );
add_filter( 'rank_math/opengraph/twitter/twitter_description', 'te_rankmath_twitter_description' );There is no single og_title filter that covers both networks. Hook only the Facebook one and the Twitter Card title falls back to whatever Rank Math derived. Set both, or set the SEO title and let Rank Math derive the social tags from it (its default when the social fields are empty).
Rewrite-driven pages and the canonical
The case that justifies doing this in code is a URL like /deals/london/ served by one template, with the city in a custom query var registered with add_rewrite_tag(). There is no post to open in the editor, so the filter is the only place the title, description and canonical exist:
add_filter( 'rank_math/frontend/title', function ( $title ) {
$city = get_query_var( 'te_deal_city' );
if ( $city ) {
$city = ucwords( str_replace( '-', ' ', $city ) );
return sprintf( 'Deals in %s - %s', $city, get_bloginfo( 'name' ) );
}
return $title;
} );
add_filter( 'rank_math/frontend/description', function ( $description ) {
$city = get_query_var( 'te_deal_city' );
if ( $city ) {
$city = ucwords( str_replace( '-', ' ', $city ) );
return sprintf( 'Browse the latest verified deals in %s, updated daily.', $city );
}
return $description;
} );
add_filter( 'rank_math/frontend/canonical', function ( $canonical ) {
$city = get_query_var( 'te_deal_city' );
if ( $city ) {
return home_url( '/deals/' . sanitize_title( $city ) . '/' );
}
return $canonical;
} );The same gating works with is_page( 'pricing' ) or is_tax( 'product_brand' ) (read the term with get_queried_object()). Keep every callback returning the original argument when the condition does not match: a filter that returns an empty string on the skipped branch blanks the title or description on every other page of the site, which is the most common way these snippets go wrong. If Rank Math is inactive on an environment, the filters never fire, so a must-use plugin holding them is a harmless no-op and needs no class check.
Read Rank Math's stored title and description
To reuse what an editor typed into the Rank Math box (a custom card, a JSON feed, an email), read the post meta keys rank_math_title and rank_math_description:
function te_rankmath_seo_title( $id ) {
$stored = get_post_meta( $id, 'rank_math_title', true );
return $stored !== '' ? $stored : get_the_title( $id );
}Two caveats. When the field is left empty and Rank Math generates the value from its global template, the meta key is never written, so get_post_meta() returns an empty string and you need the fallback above. And the stored title can contain template variables like %title% or %sep%; hook the frontend filter instead when you need the rendered string, since it fires after Rank Math expands those tokens.
Stop Rank Math printing a tag on one page
When a template renders its own <title>, canonical and Open Graph tags, return an empty string from the matching frontend filter for that template only. The same works for the description and canonical filters:
add_filter( 'rank_math/frontend/title', function ( $title ) {
if ( is_page_template( 'template-custom-head.php' ) ) {
return '';
}
return $title;
} );Suppress only the specific tags your template replaces rather than tearing out the whole head. For a broader sweep of core and plugin head output, see clean up wp_head in WordPress.
Core only: pre_get_document_title plus a wp_head meta tag
With no SEO plugin installed, WordPress core owns the title via wp_get_document_title(), and it does not output a meta description at all. So the title and the description are two separate jobs.
For the title, pre_get_document_title short-circuits the whole generator: return a non-empty string and core uses it verbatim, skipping its normal title assembly.
add_filter( 'pre_get_document_title', 'te_core_filter_title' );
function te_core_filter_title( $title ) {
if ( ! is_singular( 'product' ) ) {
return $title; // empty string -> core builds the title normally
}
return 'Buy ' . get_the_title() . ' | Acme';
}If you only want to tweak the parts (page title, separator, site name) rather than replace the whole string, hook document_title_parts instead and edit the array members, leaving the rest to core.
For the description, there is nothing to filter, because core never prints one. You output the tag yourself on wp_head:
add_action( 'wp_head', 'te_core_print_metadesc', 1 );
function te_core_print_metadesc() {
if ( ! is_singular( 'product' ) ) {
return; // print nothing on other contexts
}
$description = 'In-stock now: ' . get_the_title() . '. Free returns within 30 days.';
printf(
'<meta name="description" content="%s">' . "\n",
esc_attr( $description )
);
}Always esc_attr() the content: it goes straight into an HTML attribute, and an unescaped quote in a post title will break the tag. The early priority (1) just keeps it tidy near the top of the head.
A portable helper that detects the active plugin
If you ship code to sites you do not control (a plugin, a reusable snippet, a client base split across Yoast and Rank Math), do not hardcode one path. Detect the active SEO plugin and hook the matching filter. Yoast registers the WPSEO_Options class; Rank Math registers a top-level RankMath class (and a RANK_MATH_FILE constant). A class_exists() check is the cheap, reliable signal:
function te_seo_active_plugin() {
if ( class_exists( 'WPSEO_Options' ) ) {
return 'yoast';
}
if ( class_exists( 'RankMath' ) ) {
return 'rankmath';
}
return 'core';
}Then wire each plugin's title and description filter to a single pair of callbacks, so your override logic lives in one place no matter what is installed:
add_action( 'init', 'te_seo_register_overrides' );
function te_seo_register_overrides() {
switch ( te_seo_active_plugin() ) {
case 'yoast':
add_filter( 'wpseo_title', 'te_seo_title' );
add_filter( 'wpseo_metadesc', 'te_seo_description' );
break;
case 'rankmath':
add_filter( 'rank_math/frontend/title', 'te_seo_title' );
add_filter( 'rank_math/frontend/description', 'te_seo_description' );
break;
default: // core only
add_filter( 'pre_get_document_title', 'te_seo_title' );
add_action( 'wp_head', 'te_seo_print_core_metadesc', 1 );
}
}
function te_seo_title( $title = '' ) {
if ( ! is_singular( 'product' ) ) {
return $title;
}
return 'Buy ' . get_the_title() . ' | Acme';
}
function te_seo_description( $description = '' ) {
if ( ! is_singular( 'product' ) ) {
return $description;
}
return 'In-stock now: ' . get_the_title() . '. Free returns within 30 days.';
}
function te_seo_print_core_metadesc() {
$description = te_seo_description( '' );
if ( '' === $description ) {
return;
}
printf(
'<meta name="description" content="%s">' . "\n",
esc_attr( $description )
);
}te_seo_title() and te_seo_description() are the only places you write your actual title and description logic; the wiring picks the right hook. The same two callbacks serve the Yoast filter, the Rank Math filter, and (for the description) the manual core wp_head print. When you are not overriding, every path returns the value it was handed, so the plugin's or core's own output passes through cleanly.
Ship it as a must-use plugin so it loads before regular plugins and survives theme switches:
<?php
/**
* Plugin Name: TE SEO Meta
* Plugin URI: https://techearl.com/wordpress-override-seo-title-meta-description
* Description: Overrides the SEO title and meta description, hooking Yoast, Rank Math, or core depending on which is active.
* Version: 1.0.0
* Author: Ishan Karunaratne
* Author URI: https://techearl.com
* License: GPL-2.0-or-later
* Text Domain: te-seo-meta
*/
// ... the te_seo_* functions above go here ...This is the approach I reach for on dynamic, rewrite-driven pages the SEO plugin cannot template: faceted listing URLs, a custom rewrite endpoint, a virtual page assembled from query vars. The plugin has no editor screen for those routes, so there is no meta box to fill in. Detect the active plugin, key the override off the query var, and the title and description are correct on a URL that does not exist as a post.
The gotcha: hooking core does nothing when a plugin is active
This is the mistake that sends people in circles. You write a clean pre_get_document_title filter, load the page, and the title in the browser tab is exactly what it was before. The filter is firing, your callback is returning the right string, and the title still does not change.
The reason: with Yoast or Rank Math active, the plugin is what actually renders the <title> tag. It does not necessarily route through wp_get_document_title() at all, and even where core builds a string, the plugin overrides the final output downstream. So your pre_get_document_title value gets computed and then discarded. Same story for the description: your hand-printed wp_head meta tag ends up as a second <meta name="description"> next to the plugin's, and the plugin's is the one that counts.
The fix is the whole point of this article: when a plugin owns the tags, hook the plugin. pre_get_document_title and a manual wp_head description are correct only on a site with no SEO plugin. The detection helper above exists precisely so you never hook the wrong layer.
Verify it
Curl the page and grep the head. Replace the URL with your own:
curl -s https://example.com/your-page/ | grep -i '<title>'
curl -s https://example.com/your-page/ | grep -i 'name="description"'What you are checking:
- The
<title>text is your overridden value. - There is exactly one
<meta name="description">and it carries your text. Two description tags means you printed a core one onwp_headwhile a plugin is also printing its own: you hooked the wrong layer, go back to the plugin's filter. - On a core-only site, confirm the description tag appears at all (core does not add one, so if your
wp_headprint is missing or conditioned out, there will be none).
When you also override the canonical and social tags, pull them all in one pass and check they agree with each other:
curl -s https://example.com/reports/uptime/ | grep -iE '<title>|og:title|twitter:title|name="description"|rel="canonical"'If the <title> changed but og:title did not, you forgot the Open Graph filter. If an unrelated page (the home page, a normal post) also shows your override or a blank tag, a callback is not returning its original argument on the no-match path. On Rank Math, also check the network-namespaced filter name (rank_math/opengraph/facebook/og_title, not rank_math/frontend/og_title).
If the title still will not change, the usual causes are: a page cache serving stale HTML (purge it), hooking pre_get_document_title while a plugin is active (the gotcha above), or your conditional (is_singular, a query var) not matching the request you are testing. Dropping a quick error_log() inside the callback confirms it is running at all, and a filter attached too early will not see the query var.
Rank Math vs Yoast: which to use
If you are picking the plugin rather than overriding one you already run: Rank Math's free tier covers most of what Yoast Premium charges $118.80/year (ex VAT) for, with broader schema out of the box and a lighter footprint. For most new WordPress sites the honest pick is Rank Math. For a team already trained on Yoast, do not switch without a specific reason. Both do the same core job (titles and descriptions, XML sitemaps, basic schema, breadcrumbs, on-page checks), and both expose the filters above, so the override code on this page works whichever you choose.
Feature comparison
| Feature | Rank Math Free | Yoast Free | Rank Math Pro | Yoast Premium |
|---|---|---|---|---|
| Title & meta description editing | Yes | Yes | Yes | Yes |
| XML sitemap | Yes | Yes | Yes | Yes |
| Focus keywords per post | 5 | 1 | Unlimited | 5 |
| Breadcrumbs | Yes | Yes | Yes | Yes |
| Schema markup (Article, BreadcrumbList) | Yes | Yes | Yes | Yes |
| Schema markup (Product, FAQ, HowTo, Recipe, Event, etc.) | Yes (20+ types, configured per post) | FAQ + HowTo blocks (others via paid add-ons) | Yes (richer + more types) | FAQ + HowTo blocks; richer types via Premium / add-ons |
| Redirection manager | Yes | No (Premium only) | Yes | Yes |
| 404 monitor | Yes | No | Yes | No |
| Internal linking suggestions | Limited (Link Genius core) | No | Yes (Link Genius + Content AI) | Yes |
| Local SEO | Basic Local SEO module included | No (Local add-on) | Richer multi-location via Pro | Included in Premium since 2024 |
| News SEO | No | No | Add-on | Included in Premium since 2024 |
| Video SEO | No | No | Add-on | Included in Premium since 2024 |
| WooCommerce SEO | Limited | No | Pro | Add-on |
| Multilingual support (WPML/Polylang) | Basic | Basic | Better | Better |
| AI title/meta generation | Limited | No | Content AI add-on | Yoast AI (Premium) |
| Bulk meta editing | Yes | Yes (Tools > Bulk editor) | Yes | Yes |
Rank Math's free tier overlaps heavily with Yoast Premium, especially after Yoast bundled Local SEO, Video SEO and News SEO into Premium in 2024. Free Rank Math ships five focus keywords per post (Yoast free has one), a redirection manager, a 404 monitor, schema for 20+ content types and bulk title and meta editing from the All Posts list (Yoast free has a bulk editor too, under Tools). Yoast's free tier is more conservative on purpose, because its revenue model depends on upgrades; only WooCommerce SEO is still sold separately, as its own product that includes Premium.

Schema, performance and the editor
Schema is the most underrated difference. Rank Math lets an editor pick and configure the schema type per post in the free version: Article, FAQ, HowTo, JobPosting, LocalBusiness, Person, Product, Recipe, Restaurant, Service, SoftwareApplication, Event, Course, Book and Video. Yoast's out-of-the-box graph is Article, BreadcrumbList, Organization, Person, WebPage and WebSite; richer types go through the developer-facing Yoast Schema API or add-ons, so an everyday editor cannot configure JobPosting or Recipe schema in core Yoast. Google has narrowed rich-result eligibility for some types (FAQPage rich results were limited to authoritative health and government sites in 2023), but structured data still helps AI engines parse and cite a page.
Performance: both plugins are light enough for a typical marketing site, and I have not seen a clean public benchmark that settles which is lighter. If it matters for your stack, measure it rather than trusting anyone's chart: install Query Monitor, activate one plugin at a time, and compare database queries on a front-end request, peak PHP memory on the block editor screen, and the editor's JavaScript payload in the browser's network panel, taking the median of several cold-cache loads. On a site with a few hundred posts the difference is noise; on a large publisher, WooCommerce store or directory site, it is worth those ten minutes.
The editor: Yoast's green, yellow and red traffic lights for SEO and readability are simplistic, but they work as a teaching tool for non-technical writers. Rank Math runs more checks and shows a percentage score in a denser, more developer-oriented UI. A client team trained on Yoast usually adapts faster to Yoast; a developer-run workflow is fine on either. On AI, Yoast AI (title, meta and intro suggestions) is included in Premium, while Rank Math's Content AI is a separate token-based subscription.
Rank Math and Yoast pricing
Regular list prices as of November 2026, ex VAT. Both vendors change prices often, and Rank Math was running a Black Friday sale when I checked (sale renewals stay at the sale price), so confirm on the pricing pages linked in the sources before you budget:
| Tier | Rank Math | Yoast |
|---|---|---|
| Free | $0 | $0 |
| Entry (Rank Math PRO, unlimited personal sites / Yoast Premium, 1 site) | $8.99/mo billed annually ($107.88/yr) | $118.80/year |
| Business (Rank Math 100 client sites, 200 during the current offer / Yoast 5 Premium subscriptions) | $27.99/mo billed annually ($335.88/yr) | about $564/year (5% bulk discount) |
| Agency (Rank Math 500 client sites, 750 during the current offer / Yoast 10 Premium subscriptions) | $64.99/mo billed annually ($779.88/yr) | about $1,010/year (15% bulk discount) |
| Content AI / Yoast AI | Sold separately (annual plans, limited free usage) | Yoast AI included in Premium |
| Local SEO add-on | Basic in Free; richer in Pro | Bundled in Premium since 2024 |
| News SEO add-on | Bundled in Pro | Bundled in Premium since 2024 |
| Video SEO add-on | Bundled in Pro | Bundled in Premium since 2024 |
| WooCommerce SEO | Bundled in Pro | Separate product at $178.80/year (includes Premium) |
Rank Math is cheaper per site at every tier above the entry plan. The Agency tier works out to about $1.56 per site per year across 500 sites at the regular price, far below equivalent Yoast Premium coverage.

Migrating between Rank Math and Yoast
The friction is asymmetric. Yoast to Rank Math is built in: Rank Math's Setup Wizard detects Yoast and imports titles, descriptions, focus keywords, redirections and schema settings, usually in minutes. Rank Math to Yoast has no importer in core Yoast; third-party migration plugins vary in reliability, and a manual SQL or WP-CLI move is tedious on thousands of posts. If you are unsure and might switch later, start with Rank Math, because the way back is harder than the way in.
Whichever direction, the importer moves the data and this checklist catches what importers miss. Run every item before deactivating the old plugin on production:
- Full database snapshot.
wp db export - | gzip > pre-migration-$(date +%Y%m%d).sql.gz, thengzip -tthe file to confirm the archive is intact. (wp db exportwrites plain SQL; naming the file.gzdoes not compress it, so pipe stdout throughgzip.) The rollback path depends on this single file. - Inventory the redirects. Export the old plugin's redirect rules to CSV (both plugins support this). Verify the importer loaded every row into the new plugin and that the source/destination URLs survived exactly. Sample 10 manually with curl.
- Inventory the canonical overrides. Any post where the editor manually set a custom canonical URL is high-risk. Export the old
_yoast_wpseo_canonicalorrank_math_canonical_urlpost meta values, confirm they re-attached to the new plugin's canonical field after import. - Sample 20 post titles and meta descriptions. Pick 5 high-traffic, 5 cornerstone, 5 random, 5 lowest-traffic. Compare the rendered
<title>and<meta name="description">in production HTML against what the new plugin shows in its admin. Any drift means the import dropped data. - Validate schema on representative URLs. Run Google's Rich Results Test on one of each: homepage, blog post, product (if WooCommerce), local-business page (if Local SEO). Confirm the schema types you expected are emitted and pass validation.
- Resubmit the sitemap to Search Console. The sitemap URL stays at
/sitemap_index.xmlfor both plugins in their default config, but the contents differ. Force a recrawl via Search Console. - Set up Search Console monitoring for the first 14 days. Index coverage, manual actions, page experience. Sudden drops in indexed pages or impressions are the early signal that something broke.
- Rollback plan in writing. Document the exact sequence: deactivate new plugin, reactivate old plugin, restore the pre-migration snapshot, force Search Console recrawl. Anyone on the team should be able to execute it from the doc in under 30 minutes.
For the WP-CLI side of a migration that gets complex, see AI-assisted WP-CLI workflows.
Which one I pick
Rank Math is my default on new builds: free-tier breadth, schema coverage, the lighter footprint and agency pricing all favour it. Pick it when you have no strong existing preference, when cost or schema breadth matters, when you run many client sites, or when you want redirections and 404 monitoring without another plugin. Stay on Yoast when you inherited a Yoast site with a trained editorial team (retraining and migration risk usually exceed the savings), when a non-technical team needs the most guided editor, or when the client already pays for Yoast's add-on ecosystem. Yoast is still a fine plugin; it just no longer beats more features for less money in the free tier.
Because Yoast, not core, renders the <title> tag once it is active. Your pre_get_document_title callback still runs and returns the right string, but Yoast produces the final title downstream and your value is discarded.
Hook wpseo_title instead. The core filter only has the last word on a site with no SEO plugin installed.
Use rank_math/frontend/title for the title and rank_math/frontend/description for the meta description. Both are applied on the front end as Rank Math builds its head output.
Return your own value to override, or return the value you were passed to leave Rank Math's own title or description in place.
Detect the active plugin and hook the matching filter. Check class_exists('WPSEO_Options') for Yoast and class_exists('RankMath') for Rank Math; fall back to core when neither is present.
Wire each plugin's title and description hook to a single pair of callbacks so your override logic lives in one place. The portable helper above does exactly this.
No. Core manages the <title> through wp_get_document_title(), but it never prints a <meta name="description"> tag. That tag only appears because an SEO plugin (or your theme) adds it.
On a core-only site you print the tag yourself on wp_head and esc_attr() the content. There is no description filter to hook because there is no description to filter.
No. The wpseo_title and wpseo_metadesc filters are part of Yoast SEO free, not a Premium-only feature, so a code override works on the free plugin.
Note that since Yoast 14.x the wpseo_metadesc filter passes a second argument (the presentation object); declare it with add_filter( ..., 10, 2 ) if you want that context, or take a single argument and ignore it.
The social tags are filtered separately. On Yoast, overriding wpseo_title leaves og:title and twitter:title on Yoast's own templates; add wpseo_opengraph_title and wpseo_twitter_title (and the matching description filters), ideally with one shared callback.
On Rank Math the Open Graph filters are network-namespaced as rank_math/opengraph/{network}/{property}, so rank_math/opengraph/facebook/og_title and rank_math/opengraph/twitter/twitter_title are separate hooks. Set both, or override the SEO title and let Rank Math derive the social tags from it.
In post meta. Yoast uses _yoast_wpseo_title and _yoast_wpseo_metadesc; Rank Math uses rank_math_title and rank_math_description. Read them with get_post_meta( $id, $key, true ).
The raw values can contain unexpanded template variables (%%title%% in Yoast, %title% in Rank Math), and Rank Math writes no key at all when the field is left on its global template. When you want the rendered text, use the value the frontend filter hands you.
Those pages have no post, so there is no meta box to fill in. Read your custom query var with get_query_var() inside the plugin's title and description filters and return the values for that case.
Set the canonical the same way (wpseo_canonical or rank_math/frontend/canonical) so each generated URL is self-canonical. Both plugins tend to guess a wrong canonical on virtual URLs otherwise.
Return an empty string from rank_math/frontend/title, gated by a condition such as is_page_template(). The same works for the description and canonical filters.
Suppress only the tags your template renders itself rather than the whole head block.
For most new sites, Rank Math: its free tier includes redirections, a 404 monitor, five focus keywords and per-post schema types that Yoast gates behind Premium or add-ons, and it is lighter on resources. Stay on Yoast when an editorial team is already trained on it and the switching cost outweighs the savings.
Yes. Rank Math's Setup Wizard imports Yoast titles, descriptions, focus keywords, redirections and schema settings. Snapshot the database first, then check redirects, canonical overrides and a sample of rendered titles before deactivating Yoast. Going the other way is harder, because core Yoast has no Rank Math importer.
Prefer a must-use plugin in wp-content/mu-plugins/. It loads automatically and survives theme switches, so a site-wide title rule does not vanish when you change themes.
The functions.php version works identically but is tied to the active theme, which makes it easy to lose track of.
See also
- Clean Up wp_head in WordPress: trimming the rest of the head output (shortlink, feeds, oEmbed, version meta) once you control the title and description
Sources
Authoritative references this article was fact-checked against.
- Yoast SEO Titles API: wpseo_title filter (Yoast developer portal)developer.yoast.com
- Rank Math frontend meta data filters: rank_math/frontend/title and /descriptionrankmath.com
- pre_get_document_title filter: WordPress Developer Referencedeveloper.wordpress.org
- Frontend Filters and Hooks: Rank Math Developer Documentationrankmath.com
- Filters, Hooks and API: Rank Math Knowledge Baserankmath.com
- add_filter(): WordPress Developer Referencedeveloper.wordpress.org
- Metadata API: Yoast SEO developer documentationdeveloper.yoast.com
- get_post_meta(): WordPress Developer Referencedeveloper.wordpress.org
- Rank Math (official site)rankmath.com
- Yoast SEO (official site)yoast.com
- Rank Math pricingrankmath.com
- Yoast SEO Premiumyoast.com
- Yoast bulk subscription discountsyoast.com
- Yoast WooCommerce SEOyoast.com
- Configuration guide for Yoast SEO (Tools and the Bulk editor)yoast.com
- Rank Math AI pricingrankmath.com
- WP-CLI: wp db exportdeveloper.wordpress.org





