add rank-description
This commit is contained in:
22
inc/rank-description.php
Normal file
22
inc/rank-description.php
Normal 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); // Высокий приоритет
|
||||||
Reference in New Issue
Block a user