correct descript
This commit is contained in:
@@ -533,7 +533,15 @@ function custom_meta_tags() {
|
||||
|
||||
$post = get_post(); // Получаем объект текущего поста или страницы
|
||||
$title = get_the_title($post).' - '.$sitename; // Получаем заголовок текущего поста или страницы
|
||||
$description = get_the_excerpt($post); // Получаем отрывок текущего поста или страницы
|
||||
$excerpt = get_the_excerpt($post);
|
||||
|
||||
if (has_excerpt()) {
|
||||
$description = $excerpt;
|
||||
} elseif (strlen($excerpt) > 300) {
|
||||
$description = wp_trim_words($excerpt, 30, '...');
|
||||
} else {
|
||||
$description = $excerpt;
|
||||
}
|
||||
|
||||
$tags = get_the_tags($post); // Получаем теги текущего поста или страницы
|
||||
$keywords = ''; // Переменная для хранения ключевых слов
|
||||
@@ -578,6 +586,7 @@ function custom_meta_tags() {
|
||||
$og_tags .= '<meta property="og:title" content="'. esc_html($title) .'" />'. PHP_EOL;
|
||||
}
|
||||
if (!empty($description)) {
|
||||
$description = wp_strip_all_tags($description);
|
||||
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">'. PHP_EOL;
|
||||
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />'. PHP_EOL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user