correct micro newsArcticle

This commit is contained in:
Andrey Kuvshinov
2025-07-13 23:40:52 +03:00
parent 8fc8cbae32
commit 160dc14a7a
3 changed files with 18 additions and 12 deletions

View File

@@ -1,17 +1,22 @@
<!--[micro/post]-->
<link itemprop="mainEntityOfPage" href="<?= get_permalink(); ?>"/>
<meta itemprop="inLanguage" content="ru"/>
<meta itemprop="headline name" content="<?= htmlspecialchars( get_the_title() ) ?>" />
<meta itemprop="dateModified" content="<?= the_modified_date("c"); ?>"/>
<?php // Получаем текущие рубрики поста
$categories = get_the_category();
if (!empty($categories)) {
// Берём первую рубрику (можно изменить логику при необходимости)
$current_category = $categories[0]->name;
$microcategory = $categories[0]->name;
} elseif ( in_array( get_post_type(), ["anew", "yellow"] ) && !is_tag() && !is_category() ){
$microcategory = 'Новости';
}
echo '<meta itemprop="articleSection" content="' . $microcategory . '">';
?>
<?php
get_template_part("template-parts/micro/terms");
//get_template_part("template-parts/micro/terms");
?>
<!--[/micro/post]-->

View File

@@ -2,7 +2,7 @@
<div class="d-none">
<?php foreach (wp_get_post_terms( get_the_ID(), ["category", "post_tag"] ) as $term) : ?>
<?php foreach (wp_get_post_terms( get_the_ID(), ["category"] ) as $term) : ?>
<span itemprop="articleSection">