add rank-description

This commit is contained in:
masterforweb
2026-01-12 16:56:51 +03:00
parent 2aff9ab6b1
commit ed66701325

22
inc/rank-description.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
add_filter('rank_math/frontend/description', function($description) {
global $post;
if ($post) {
// Получаем OG description из метаполей RankMath
$og_desc = get_post_meta($post->ID, 'rank_math_facebook_description', true);
if (!empty($og_desc)) {
return $og_desc;
}
// Если нет отдельного для FB, берем общий social description
$social_desc = get_post_meta($post->ID, 'rank_math_twitter_description', true);
if (!empty($social_desc)) {
return $social_desc;
}
}
return $description; // Возвращаем исходный, если ничего не нашли
}, 99); // Высокий приоритет