{$product_name} SEO Score
{$score}/100 - " . ($score >= 70 ? 'Good' : ($score >= 40 ? 'Needs Improvement' : 'Poor')) . "
";
});
function get_rankmath_seo_score($post_id) {
if (!class_exists('RankMath\Helper')) return null;
// Try primary method
if (function_exists('rank_math')) {
$score = rank_math()->score->get_score($post_id);
if (is_numeric($score)) return (int) $score;
}
// Check all possible meta keys
$keys = apply_filters('rankmath/seo_score_meta_keys', [
'rank_math_seo_score',
'rank_math_score',
'rank_math_analytic_score',
'rank_math_content_ai_score'
]);
foreach ($keys as $key) {
$value = get_post_meta($post_id, $key, true);
if (is_numeric($value)) return (int) $value;
}
return null;
}