correct descript

This commit is contained in:
2024-03-15 22:53:02 +03:00
parent 801624e554
commit 2b135a2bca
2 changed files with 13 additions and 2 deletions

View File

@@ -3,6 +3,8 @@
line-height: 1.6rem; line-height: 1.6rem;
padding: 0.1rem 1.2rem; padding: 0.1rem 1.2rem;
border: 1px solid var(--white); border: 1px solid var(--white);
color: var(--white); background-color: #fff;
color: black;
border-radius: 5rem; border-radius: 5rem;
opacity: 8;
} }

View File

@@ -533,7 +533,15 @@ function custom_meta_tags() {
$post = get_post(); // Получаем объект текущего поста или страницы $post = get_post(); // Получаем объект текущего поста или страницы
$title = get_the_title($post).' - '.$sitename; // Получаем заголовок текущего поста или страницы $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); // Получаем теги текущего поста или страницы $tags = get_the_tags($post); // Получаем теги текущего поста или страницы
$keywords = ''; // Переменная для хранения ключевых слов $keywords = ''; // Переменная для хранения ключевых слов
@@ -578,6 +586,7 @@ function custom_meta_tags() {
$og_tags .= '<meta property="og:title" content="'. esc_html($title) .'" />'. PHP_EOL; $og_tags .= '<meta property="og:title" content="'. esc_html($title) .'" />'. PHP_EOL;
} }
if (!empty($description)) { if (!empty($description)) {
$description = wp_strip_all_tags($description);
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">'. PHP_EOL; $meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">'. PHP_EOL;
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />'. PHP_EOL; $og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />'. PHP_EOL;
} }