add files
This commit is contained in:
43
template-parts/breadcrumbs.php
Normal file
43
template-parts/breadcrumbs.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if ( ! is_single() ) return;
|
||||
|
||||
// Рекурсивная функция с Schema.org позицией
|
||||
function render_full_category_breadcrumbs( $cat_id, &$position = 1, $separator = ' > ' ) {
|
||||
$cat = get_category( $cat_id );
|
||||
if ( ! $cat ) return;
|
||||
|
||||
// Рекурсивно выводим родителей
|
||||
if ( $cat->parent != 0 ) {
|
||||
render_full_category_breadcrumbs( $cat->parent, $position, $separator );
|
||||
}
|
||||
|
||||
// Выводим категорию с Schema.org структурой
|
||||
echo '<li property="itemListElement" typeof="ListItem" itemprop="itemListElement">
|
||||
<a property="item" typeof="WebPage" href="' . esc_url( get_category_link( $cat->term_id ) ) . '">
|
||||
<span property="name" itemprop="name">' . esc_html( $cat->name ) . '</span>
|
||||
</a>
|
||||
<meta property="position" content="' . $position . '" />
|
||||
</li>';
|
||||
|
||||
$position++;
|
||||
}
|
||||
|
||||
$categories = get_the_category();
|
||||
if ( empty( $categories ) ) return;
|
||||
|
||||
$main_cat = $categories[0];
|
||||
$breadcrumb_position = 1;
|
||||
?>
|
||||
|
||||
<nav class="breadcrumbs" aria-label="Навигация по рубрикам" itemscope itemtype="https://schema.org/BreadcrumbList">
|
||||
<ol class="breadcrumbs_list" itemprop="itemListElement">
|
||||
<?php render_full_category_breadcrumbs( $main_cat->term_id, $breadcrumb_position ); ?>
|
||||
<li property="itemListElement" typeof="ListItem">
|
||||
<span property="item" typeof="WebPage" itemprop="name"><?php the_time('j F Y, H:i \М\С\К'); ?></span>
|
||||
<meta property="position" content="<?php echo ++$breadcrumb_position; ?>" />
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
59
template-parts/content-card.php
Normal file
59
template-parts/content-card.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// template-parts/content-card.php
|
||||
$post_id = get_the_ID();
|
||||
?>
|
||||
<div class="news-item">
|
||||
<?php if (has_post_thumbnail()) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php the_post_thumbnail('medium-thumbnail'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2 class="news-item-title">
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</h2>
|
||||
|
||||
<?php
|
||||
// Проверяем, является ли это страницей тега
|
||||
if (is_tag()) {
|
||||
// Получаем все категории поста
|
||||
$categories = get_the_category();
|
||||
|
||||
if (!empty($categories)) {
|
||||
// Находим самую первую родительскую категорию
|
||||
$top_parent = $categories[0];
|
||||
|
||||
// Если у категории есть родитель, поднимаемся вверх по иерархии
|
||||
while ($top_parent->parent != 0) {
|
||||
$top_parent = get_category($top_parent->parent);
|
||||
}
|
||||
|
||||
// Выводим родительскую категорию
|
||||
echo '<div class="news-item-info">';
|
||||
echo '<span class="news-item-info-part">';
|
||||
echo '<a href="' . esc_url(get_category_link($top_parent->term_id)) . '">';
|
||||
echo esc_html($top_parent->name);
|
||||
echo '</a>';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
// Если это не страница тега, используем существующую логику
|
||||
$subcategory = get_first_subcategory($post_id);
|
||||
if ($subcategory) :
|
||||
?>
|
||||
<div class="news-item-info">
|
||||
<span class="news-item-info-part">
|
||||
<a href="<?php echo esc_url($subcategory['url']); ?>">
|
||||
<?php echo esc_html($subcategory['name']); ?>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
13
template-parts/content-cards.php
Normal file
13
template-parts/content-cards.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// template-parts/content-cards.php
|
||||
|
||||
// Проверяем, есть ли записи в текущем запросе
|
||||
if (have_posts()) : ?>
|
||||
<div class="news-block">
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<?php get_template_part('template-parts/content', 'card'); ?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p>Записей не найдено.</p>
|
||||
<?php endif; ?>
|
||||
28
template-parts/current-datetime.php
Normal file
28
template-parts/current-datetime.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- Строка с датой и временем -->
|
||||
<div class="header-top-bar">
|
||||
<div class="header-top-content">
|
||||
<span id="current-datetime">
|
||||
<?php
|
||||
// Массивы для русских названий
|
||||
$months_ru = [
|
||||
1 => 'января', 2 => 'февраля', 3 => 'марта', 4 => 'апреля',
|
||||
5 => 'мая', 6 => 'июня', 7 => 'июля', 8 => 'августа',
|
||||
9 => 'сентября', 10 => 'октября', 11 => 'ноября', 12 => 'декабря'
|
||||
];
|
||||
|
||||
$days_ru = [
|
||||
0 => 'Воскресенье', 1 => 'Понедельник', 2 => 'Вторник',
|
||||
3 => 'Среда', 4 => 'Четверг', 5 => 'Пятница', 6 => 'Суббота'
|
||||
];
|
||||
|
||||
$day = date('j');
|
||||
$month = $months_ru[date('n')];
|
||||
$year = date('Y');
|
||||
$day_name = $days_ru[date('w')];
|
||||
$time = date('H:i');
|
||||
|
||||
echo "$day $month $year, $day_name | Московское время: $time";
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
68
template-parts/share-buttons.php
Normal file
68
template-parts/share-buttons.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
$post_url = esc_url( get_permalink() );
|
||||
$post_title = esc_html( get_the_title() );
|
||||
?>
|
||||
|
||||
<div class="share-panel">
|
||||
<div class="share-panel-title">
|
||||
Поделитесь с друг<span class="share-panel-inoi">ими</span>
|
||||
</div>
|
||||
|
||||
<div class="share-panel-buttons">
|
||||
<!-- VK -->
|
||||
<div class="share-panel-element">
|
||||
<a href="http://vk.com/share.php?url=<?= $post_url ?>&title=<?= $post_title ?>"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
aria-label="Поделиться в ВКонтакте">
|
||||
<i class="social-icon social-icon-vk" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Telegram -->
|
||||
<div class="share-panel-element">
|
||||
<a href="https://t.me/share/url?url=<?= $post_url ?>&text=<?= $post_title ?>"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
aria-label="Поделиться в Telegram">
|
||||
<i class="social-icon social-icon-tg" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Одноклассники -->
|
||||
<div class="share-panel-element">
|
||||
<a href="https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=<?= $post_url ?>"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
aria-label="Поделиться в Одноклассниках">
|
||||
<i class="social-icon social-icon-ok" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$subject = get_the_title().' - Спортпресса';
|
||||
$body = "Читайте на сайте Спортпресса:\n" . get_permalink();
|
||||
|
||||
$mailto = 'mailto:?subject=' . rawurlencode($subject) . '&body=' . rawurlencode($body);
|
||||
?>
|
||||
|
||||
|
||||
<div class="share-panel-element">
|
||||
<a href="<?php echo esc_attr($mailto); ?>"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
aria-label="Отправить на email">
|
||||
<i class="social-icon social-icon-email" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="share-panel-element">
|
||||
<a class="js-copy-link" href="<?php echo esc_attr($mailto); ?>"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
data-copy="<?php echo esc_url( get_permalink() ); ?>"
|
||||
aria-label="Отправить ссылку">
|
||||
<i class="social-icon social-icon-link" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
4
template-parts/subscripts.php
Normal file
4
template-parts/subscripts.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="subscripts"> Подпишитесь на Спорт
|
||||
<a class="btn_sub_social" href="https://dzen.ru/sportpressa.ru" target="_blank"> Дзен </a>
|
||||
<a class="btn_sub_social" href="https://t.me/sportpressa" target="_blank">Telegram</a>
|
||||
</div>
|
||||
Reference in New Issue
Block a user