Andrei | blog module fixes

pull/36/head
parent 3b2f8a1a15
commit a85ae6afb6
  1. 5
      wp-content/themes/cosmopet/modules/blog/components/most-read/component-controller.php
  2. 28
      wp-content/themes/cosmopet/modules/blog/components/most-read/component-template.twig
  3. 11
      wp-content/themes/cosmopet/templates/blog/blog-archive.twig
  4. 2
      wp-content/themes/cosmopet/templates/blog/blog-single.twig
  5. 3
      wp-content/themes/cosmopet/templates/blog/most-read.twig
  6. 4
      wp-content/themes/cosmopet/templates/blog/themes.twig

@ -34,10 +34,5 @@ add_filter('timber/context', function($context) {
$context['current_category'] = $category_name; $context['current_category'] = $category_name;
$context['category_list'] = get_categories(); $context['category_list'] = get_categories();
// Отладочная информация (опционально)
global $wpdb;
$debug_info = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'post_views_count' LIMIT 5");
$context['debug_info'] = $debug_info;
return $context; return $context;
}); });

@ -1,28 +0,0 @@
<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>
{% 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>
</div>
</div>
</li>
{% endfor %}
</ul>
</div>

@ -14,13 +14,20 @@
<!-- Home end --> <!-- Home end -->
<!-- Anons --> <!-- Anons -->
<section class="anons"> <section class="anons" id="news-list">
<div class="container"> <div class="container">
{% include '/blog/themes.twig' %} {% include '/blog/themes.twig' %}
{% include '/blog/most-read.twig' %} {% include '/blog/most-read.twig' %}
<div class="anons-article"> <div class="anons-article">
<h2 class="anons-article__title">{{ function('pll_e', 'ВСЕ СТАТЬИ') }}</h2> <h2 class="anons-article__title">
{% if not fn('is_category') %}
{{ function('pll_e', 'ВСЕ СТАТЬИ') }}
{% else %}
{% set term = fn('get_queried_object') %}
{{ term.name }}
{% endif %}
</h2>
<ul class="anons-article__card-wrap"> <ul class="anons-article__card-wrap">
{% include '/blog/news-list.twig' %} {% include '/blog/news-list.twig' %}

@ -7,7 +7,7 @@
<section class="breadcrumb"> <section class="breadcrumb">
<div class="container"> <div class="container">
<a href="{{ site.url }}">{{ function('pll_e', 'Главная') }}</a> / <a href="{{ site.url }}">{{ function('pll_e', 'Главная') }}</a> /
<a href="{{ site.url }}">{{ function('pll_e', 'Блог') }}</a> / <a href="{{ fn('get_post_type_archive_link', 'post') }}">{{ function('pll_e', 'Блог') }}</a> /
<a href="{{ post.link }}">{{ post.name }}</a> <a href="{{ post.link }}">{{ post.name }}</a>
</div> </div>
</section> </section>

@ -1,5 +1,5 @@
{% set current_path = template_path ~ '/modules/blog/components/most-read' %} {% set current_path = template_path ~ '/modules/blog/components/most-read' %}
{% if not fn('is_category') %}
<div class="anons-best"> <div class="anons-best">
<h2 class="anons-best__title">{{ function('pll_e', 'САМЫЕ ЧИТАЕМЫЕ') }}:</h2> <h2 class="anons-best__title">{{ function('pll_e', 'САМЫЕ ЧИТАЕМЫЕ') }}:</h2>
@ -48,3 +48,4 @@
<p>Нет доступных постов для отображения.</p> <p>Нет доступных постов для отображения.</p>
{% endif %} {% endif %}
</div> </div>
{% endif %}

@ -2,11 +2,11 @@
<h3 class="anons-theme__title">{{ function('pll_e', 'Темы') }}:</h3> <h3 class="anons-theme__title">{{ function('pll_e', 'Темы') }}:</h3>
<ul> <ul>
<li> <li>
<a href="{{ fn('get_post_type_archive_link', 'post') }}" class="{% if not current_category %} active {% endif %}">{{ function('pll_e', 'ВСЕ') }}</a> <a href="{{ fn('get_post_type_archive_link', 'post') }}#news-list" class="{% if not current_category %} active {% endif %}">{{ function('pll_e', 'ВСЕ') }}</a>
</li> </li>
{% for category in category_list %} {% for category in category_list %}
<li> <li>
<a href="/category/{{category.slug}}" <a href="/category/{{category.slug}}#news-list"
class="{% if current_category == category.name %} active {% endif %}">{{ category.name }}</a> class="{% if current_category == category.name %} active {% endif %}">{{ category.name }}</a>
</li> </li>

Loading…
Cancel
Save