Answer the question
In order to leave comments, you need to log in
How to display related posts with the same tags (tags) as the first post?
Hello!
I have a search form, the result of which is displayed on a separate page.
How can I display similar posts (in my case, products), with the same tags (tags) as the found post (product)? You need to display them below after all the others. Help please ... I found solutions on the internet, but I can’t get the posts out in any way.
I use ACF in the output, don't be scared
<?php if ( $query->have_posts() ){ ?>
Результаты: <?php echo $query->found_posts; ?> <br />
<div class='search-filter-results-list'>
<?php while ($query->have_posts()){ $query->the_post(); ?>
<!-- Вывод данных поста -->
<div class="container">
<div class="product_description_inside_search clearfix">
<div class="product_description_inside_img">
<img src="<?php the_field('image_product') ?>">
</div>
<div class="product_title_search">
<h1>
<?php the_field('pharm_name'); ?>
</h1>
</div>
<div class="pharm_permalink">
<a href="<?php the_permalink(); ?>">Подробнее</a>
</div>
<div class="where_buy_search">
<span id="where_buy"><?php the_field('name_pharmacies'); ?></span><br>
</div>
<div class="pharm_price">
<br><h2>Цена: <?php the_field('pharm_price'); ?></h2>
</div>
</div>
</div>
<!-- Вывод данных поста -->
<?php } ?>
</div>
<?php } else { ?>
<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
<span>Нет результатов</span>
</div>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question