I
I
Ivan Gordienko2019-10-09 10:10:46
WordPress
Ivan Gordienko, 2019-10-09 10:10:46

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(); ?>


Here is the results page -
<?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'); ?> &#x20bd;</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>


The posts themselves are displayed, pagination works, a separate search via <?php echo get_search_query() ?> on the main page also works, but this one does not work.

5d9d879f31c27857111591.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Gordienko, 2019-10-12
@zordq

I'm an idiot, I forgot wp_head().
My advice to you, don't forget about wp_head()!

W
WP Panda, 2019-10-09
@wppanda5

AJAX not working

What does the console say about this? And developer tools.
Typically for AJAX , the cause of the error is easy to track down there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question