Forums Forums Search & Filter Pro How to show results with Ajax

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #221612

    Hi,

    Just purchased the plugin and am trying to set it up, I’ve sorted the forms and fields but whenever I change somethingit takes me to another page.

    I already have a page which lists all of the results using the WP Query I just need to filter them which I thought this plugin could do?

                <?php
                $args = array(
                  'post_type'   => 'partner',
                  'post_status' => 'publish',
                 );
    
                $partners = new WP_Query( $args );
                if( $partners->have_posts() ) :
                ?>
                  <ul>
                    <?php
                      while( $partners->have_posts() ) :
                        $partners->the_post();
                        ?>
                          <li><?php printf( '%1$s - %2$s', get_the_title(), get_the_content() );  ?></li>
                        <?php
                      endwhile;
                      wp_reset_postdata();
                    ?>
                  </ul>
                <?php
                else :
                  esc_html_e( 'No partners!', 'text-domain' );
                endif;
                ?>

    How can I make the filter work with the query on this page please?

    Anonymous
    #221617

    I’ve also tried adding in the search filter ID into the query:

                $args = array(
                  'post_type'   => 'partner',
                  'post_status' => 'publish',
                 );
                $args['search_filter_id'] = 6688;
                $partners = new WP_Query( $args );

    Which I saw on this page: https://searchandfilter.com/documentation/search-results/custom/

    Do I need to somehow include the taxonomies into the query? I have three custom ones at the moment.

    Trevor
    #221670
    This reply has been marked as private.
    Anonymous
    #221737
    This reply has been marked as private.
    Trevor
    #221822

    I have switched OFF Ajax and it seems to work for me. Looking at your code, change the <ul> to add a class, like this:

    <ul class="search-results">

    and the change the Ajax Container from #main to .search-results

    Then switch Ajax back on and test. Please let me know how you get on?

    Anonymous
    #221847

    Hi Trevor,

    I did as you asked, and now when selecting different options on the front end it appears to load something but the results don’t actually change.

    Trevor
    #221879

    The results <ul> does not have the class added?

    https://www.screencast.com/t/Bj6iuivS7EQ

Viewing 7 posts - 1 through 7 (of 7 total)