22 lines
786 B
PHP
22 lines
786 B
PHP
|
|
<?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); // Высокий приоритет
|