47. Migration from Rank Math | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

47. Migration from Rank Math

Developer Guide

The built-in migration tool also supports Rank Math. It reads data directly from the database.

What Gets Migrated

Rank Math Meta KeySEO Forge Meta Key
rank_math_title_seoforge_meta_title
rank_math_description_seoforge_meta_description
rank_math_focus_keyword_seoforge_focus_keyword
rank_math_robots (noindex)_seoforge_noindex
rank_math_robots (nofollow)_seoforge_nofollow
rank_math_canonical_url_seoforge_canonical_url
rank_math_facebook_title_seoforge_og_title
rank_math_facebook_description_seoforge_og_description
rank_math_facebook_image_seoforge_og_image
rank_math_twitter_title_seoforge_twitter_title
rank_math_twitter_description_seoforge_twitter_description

Custom Rank Math canonical URLs (rank_math_canonical_url) are imported into _seoforge_canonical_url.

Manual Rank Math Migration

php
global $wpdb;

// Migrate Rank Math descriptions
$rm_meta = $wpdb->get_results(
    "SELECT post_id, meta_value FROM {$wpdb->postmeta}
     WHERE meta_key = 'rank_math_description' AND meta_value != ''"
);

foreach ( $rm_meta as $row ) {
    $existing = get_post_meta( $row->post_id, '_seoforge_meta_description', true );
    if ( empty( $existing ) ) {
        // Resolve Rank Math variables: %title%, %sitename%, %sep%
        $desc = str_replace(
            [ '%title%', '%sitename%', '%sep%' ],
            [ get_the_title( $row->post_id ), get_bloginfo( 'name' ), '|' ],
            $row->meta_value
        );
        update_post_meta( $row->post_id, '_seoforge_meta_description', sanitize_text_field( $desc ) );
    }
}

// Migrate Rank Math robots meta
$robots_meta = $wpdb->get_results(
    "SELECT post_id, meta_value FROM {$wpdb->postmeta}
     WHERE meta_key = 'rank_math_robots'"
);

foreach ( $robots_meta as $row ) {
    $robots = maybe_unserialize( $row->meta_value );
    if ( is_array( $robots ) ) {
        if ( in_array( 'noindex', $robots, true ) ) {
            update_post_meta( $row->post_id, '_seoforge_noindex', '1' );
        }
        if ( in_array( 'nofollow', $robots, true ) ) {
            update_post_meta( $row->post_id, '_seoforge_nofollow', '1' );
        }
    }
}

Forge AI Assistant Online

Hi! I'm the SEO Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs