Forums › Forums › Search & Filter Pro › How to show results with Ajax
Tagged: ajax
- This topic has 6 replies, 2 voices, and was last updated 5 years, 1 month ago by Trevor.
-
Anonymous(Private) September 23, 2019 at 4:21 pm #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(Private) September 23, 2019 at 4:25 pm #221617I’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(Private) September 25, 2019 at 10:05 am #221822I 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?
-
AuthorPosts