Answer the question
In order to leave comments, you need to log in
AJAX plugin "Search & Filter" not working in search for custom_post_types in Wordpress?
Good day. There is a custom post type.
There is a page for its output, on which there is a search, this search does not work and I can not understand what is the reason.
Here is the post output page -
<?php
/* Template name: Товары */
/* Template part for displaying posts */
?>
<?php get_header(); ?>
<!--Sell Section-->
<section class="search__section">
<?php get_sidebar() ?>
<div class="search__block">
<?php echo do_shortcode( '[searchandfilter id="23" show="results"]' ); ?>
</div>
</section>
<?php get_footer(); ?>
<?php
/* Template name: Результаты */
/* Template part for displaying posts */
?>
<?php
$count_items = -1;
if ($query->have_posts()) {
?>
<br>
<span>Найдено <?php echo $query->found_posts; ?> товара (товаров)</span><br>
<!--
<span><?php echo $query->query['paged']; ?> из <?php echo $query->max_num_pages; ?><br></span>
-->
<div class="pagination"><?php next_posts_link('', $query->max_num_pages); ?></div>
<div class="nav-next"><?php previous_posts_link(''); ?></div>
<?php
if (function_exists('wp_pagenavi')) {
echo "<br>";
wp_pagenavi(array( 'query' => $query ));
} ?>
</div>
<?php
while ($query->have_posts()) {
$query->the_post(); ?>
<div class="search__block-item">
<img src="<?php the_field('image'); ?>" alt="image">
<a href="<?php the_permalink(); ?>"><span><?php the_title(); ?></span></a>
<span><?php the_field('price'); ?> ₽</span>
</div>
<?php
} ?>
<span class="page__count">Страница <?php echo $query->query['paged']; ?> из <?php echo $query->max_num_pages; ?></span><br>
<div class="pagination">
<div class="nav-previous"><?php next_posts_link('', $query->max_num_pages); ?></div>
<div class="nav-next"><?php previous_posts_link(''); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi')) {
echo "<br>";
wp_pagenavi(array( 'query' => $query ));
} ?>
</div>
<?php
} else {
echo "</br> Результатов не найдено :(";
}
?>
</div>
Answer the question
In order to leave comments, you need to log in
I'm an idiot, I forgot wp_head().
My advice to you, don't forget about wp_head()!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question