add folder EN
This commit is contained in:
33
en/related-posts-en.php
Normal file
33
en/related-posts-en.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$current_post_id = get_the_ID();
|
||||
|
||||
// Получаем категории текущего поста
|
||||
$categories = get_the_category($current_post_id);
|
||||
if ($categories) {
|
||||
$category_ids = array_map(function ($category) {
|
||||
return $category->term_id;
|
||||
}, $categories);
|
||||
|
||||
$args = array(
|
||||
'category__in' => $category_ids,
|
||||
'post__not_in' => array($current_post_id),
|
||||
'posts_per_page' => 4,
|
||||
);
|
||||
|
||||
$related_posts_query = new WP_Query($args);
|
||||
|
||||
if ($related_posts_query->have_posts()) {
|
||||
|
||||
echo '<div class="article-section__title">Read also:</div>';
|
||||
echo '<div class="articles-preview">';
|
||||
|
||||
while ($related_posts_query->have_posts()) {
|
||||
$related_posts_query->the_post();
|
||||
get_template_part('en/content', 'post-en');
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
wp_reset_postdata();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user