diff --git a/wp-content/themes/hantico/template-parts/related.php b/wp-content/themes/hantico/template-parts/related.php
index b5248da..479b5ab 100644
--- a/wp-content/themes/hantico/template-parts/related.php
+++ b/wp-content/themes/hantico/template-parts/related.php
@@ -1,15 +1,44 @@
$current_post_id]) as $field_group) {
+ foreach (acf_get_fields($field_group) ?: [] as $field) {
+ if ($field['name'] === 'article_category') {
+ return;
+ }
+ }
+ }
+ }
+
+ $selected_ids = [];
+ foreach ($selected_articles as $row) {
+ $article = $row['post'] ?? null;
+ $article_id = $article instanceof WP_Post ? $article->ID : (int) $article;
+ if ($article_id > 0 && $article_id !== $current_post_id) {
+ $selected_ids[] = $article_id;
+ }
+ }
$terms = get_the_terms($current_post_id, 'article_category');
$related_args = [
- 'post_type' => $post_type,
+ 'post_type' => $post_type === 'news' ? 'news' : 'article',
'posts_per_page' => 6,
'post__not_in' => [$current_post_id],
'orderby' => 'date',
'order' => 'DESC'
];
- if ($terms) {
+ if ($selected_ids) {
+ $related_args['post_type'] = 'article';
+ $related_args['post__in'] = $selected_ids;
+ $related_args['posts_per_page'] = -1;
+ $related_args['orderby'] = 'post__in';
+ } elseif ($terms && !is_wp_error($terms)) {
$term_ids = wp_list_pluck($terms, 'term_id');
$related_args['tax_query'] = [
[
@@ -20,6 +49,21 @@
];
}
$related_query = new WP_Query($related_args);
+ if ($selected_ids) {
+ // WP_Query removes duplicates; restore the exact order and rows from ACF.
+ $posts_by_id = [];
+ foreach ($related_query->posts as $selected_post) {
+ $posts_by_id[$selected_post->ID] = $selected_post;
+ }
+ $related_query->posts = [];
+ foreach ($selected_ids as $selected_id) {
+ if (isset($posts_by_id[$selected_id])) {
+ $related_query->posts[] = $posts_by_id[$selected_id];
+ }
+ }
+ $related_query->post_count = count($related_query->posts);
+ }
+
if ($related_query->have_posts()) :
$title = $post_type === 'news' ? 'Другие новости' : 'Вам также может понравиться';
?>
diff --git a/wp-content/themes/hantico/template-parts/reviews.php b/wp-content/themes/hantico/template-parts/reviews.php
index cc52abe..7dcabf9 100644
--- a/wp-content/themes/hantico/template-parts/reviews.php
+++ b/wp-content/themes/hantico/template-parts/reviews.php
@@ -1,5 +1,7 @@
diff --git a/wp-content/themes/hantico/templates/template-courier.php b/wp-content/themes/hantico/templates/template-courier.php
index ef25c35..88aa26b 100644
--- a/wp-content/themes/hantico/templates/template-courier.php
+++ b/wp-content/themes/hantico/templates/template-courier.php
@@ -16,7 +16,6 @@ Template Name: Курьерам
-