parent
27e6606835
commit
f77388501d
After Width: | Height: | Size: 1.5 KiB |
@ -1,3 +1,7 @@ |
||||
main{ |
||||
padding-top: 72px; |
||||
} |
||||
|
||||
.block-lists_text p { |
||||
font-size: 18px!important; |
||||
} |
@ -0,0 +1,10 @@ |
||||
@media(max-width:600px) { |
||||
.article-content h2 { |
||||
max-width: 661px; |
||||
font-size: 24px!important; |
||||
line-height: 40px; |
||||
font-weight: bold; |
||||
text-transform: uppercase; |
||||
color: var(--grey-black); |
||||
} |
||||
} |
@ -1,23 +1,22 @@ |
||||
<?php |
||||
|
||||
|
||||
add_filter('timber/context', function($context) { |
||||
$current_category = get_queried_object(); // Получаем текущую категорию |
||||
|
||||
// Простой запрос для получения последних постов |
||||
$args = array( |
||||
'post_type' => 'post', |
||||
'posts_per_page' => 3, // Количество постов |
||||
'orderby' => 'meta_value_num', |
||||
'key' => 'post_views', // Поле плагина для подсчёта просмотров |
||||
'order' => 'DESC', // Сортировка по убыванию |
||||
|
||||
// Условие для фильтрации по текущей категории |
||||
'category__in' => $current_category ? array($current_category->term_id) : '', |
||||
'posts_per_page' => 3, |
||||
'orderby' => 'date', |
||||
'order' => 'DESC' |
||||
); |
||||
|
||||
$most_read_query = new WP_Query($args); |
||||
$most_read = new Timber\PostQuery($most_read_query); |
||||
|
||||
$context['most_read'] = $most_read; |
||||
|
||||
// Добавляем отладочную информацию |
||||
global $wpdb; |
||||
$debug_info = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE meta_key LIKE '%view%' LIMIT 5"); |
||||
$context['debug_info'] = $debug_info; |
||||
|
||||
return $context; |
||||
}); |
||||
}); |
@ -1,36 +1,50 @@ |
||||
<div class="anons-best"> |
||||
<h2 class="anons-best__title">{{ function('pll_e', 'САМЫЕ ЧИТАЕМЫЕ') }}:</h2> |
||||
<ul class="anons-best__card-wrap"> |
||||
{% for post in most_read %} |
||||
<li class="anons-best__card"> |
||||
<ul class="anons-best__card-alerts"> |
||||
{% for category in post.categories %} |
||||
<li> |
||||
<a href="{{ category.link }}">{{ category.name }}</a> |
||||
</li> |
||||
|
||||
<!-- Отладочная информация --> |
||||
{% if debug_info %} |
||||
<div style="display:none;"> |
||||
<p>Метаполя с просмотрами:</p> |
||||
<ul> |
||||
{% for item in debug_info %} |
||||
<li>ID: {{ item.post_id }}, Ключ: {{ item.meta_key }}, Значение: {{ item.meta_value }}</li> |
||||
{% endfor %} |
||||
</ul> |
||||
<a href="{{post.link}}" class="main-img"> |
||||
<img src="{{post.thumbnail.src}}" alt="{{post.thumbnail.alt}}"> |
||||
</a> |
||||
<div class="anons-best__card-body"> |
||||
<a href="{{post.link}}" class="anons-best__card-body__title">{{post.title}}</a> |
||||
<div class="anons-best__card-body__datas"> |
||||
<p>{{post.date}}</p> |
||||
<p>{{ function('pll_e', 'время чтения') }}: {{post.reading_time}}</p> |
||||
<ul> |
||||
{% if post.get_author_name %} |
||||
<li class="logo"> |
||||
<img src="{{post.get_author_img}}" alt=""> |
||||
</div> |
||||
{% endif %} |
||||
|
||||
{% if most_read and most_read|length > 0 %} |
||||
<ul class="anons-best__card-wrap"> |
||||
{% for post in most_read %} |
||||
<li class="anons-best__card"> |
||||
<ul class="anons-best__card-alerts"> |
||||
{% for category in post.categories %} |
||||
<li> |
||||
<a href="{{ category.link }}">{{ category.name }}</a> |
||||
</li> |
||||
{% endfor %} |
||||
</ul> |
||||
<a href="{{ post.link }}" class="main-img"> |
||||
<img src="{{ post.thumbnail.src|default('https://via.placeholder.com/150') }}" alt="{{ post.thumbnail.alt|default(post.title) }}"> |
||||
</a> |
||||
<div class="anons-best__card-body"> |
||||
<a href="{{ post.link }}" class="anons-best__card-body__title">{{ post.title }}</a> |
||||
<div class="anons-best__card-body__datas"> |
||||
<p>{{ post.date|date('d.m.Y') }}</p> |
||||
<p>{{ function('pll_e', 'время чтения') }}: {{ post.reading_time|default('5 мин') }}</p> |
||||
<ul> |
||||
{% if post.get_author_name %} |
||||
<li class="logo"> |
||||
<img src="{{ post.get_author_img|default('https://via.placeholder.com/40') }}" alt="{{ post.get_author_name }}"> |
||||
</li> |
||||
|
||||
{% endif %} |
||||
</ul> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</li> |
||||
{% endfor %} |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
</li> |
||||
{% endfor %} |
||||
</ul> |
||||
{% else %} |
||||
<p>Нет доступных постов для отображения.</p> |
||||
{% endif %} |
||||
</div> |
Loading…
Reference in new issue