add files inc
This commit is contained in:
20
inc/meta_keywords.php
Normal file
20
inc/meta_keywords.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
add_action('wp_head', function() {
|
||||
// Для записей и страниц
|
||||
if (is_single() || is_page()) {
|
||||
$post_id = get_queried_object_id();
|
||||
|
||||
// Получаем термины из таксономии 'keys'
|
||||
$terms = get_the_terms($post_id, 'keys');
|
||||
|
||||
if ($terms && !is_wp_error($terms)) {
|
||||
$keywords = array();
|
||||
foreach ($terms as $term) {
|
||||
$keywords[] = $term->name;
|
||||
}
|
||||
|
||||
echo '<meta name="keywords" content="' . esc_attr(implode(', ', $keywords)) . '">' . "\n";
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user