Forums › Forums › Search & Filter Pro › Show results on same page + filters not working
Tagged: filters not working, same page results, V3
- This topic has 38 replies, 2 voices, and was last updated 6 years, 4 months ago by Anonymous.
-
Anonymous(Private) August 10, 2018 at 8:36 pm #185206
Hey people, just bought the plugin and I’m facing some issues here.
I’m developing an essays collection site, with over 800 philosophy essays. The main feature is the search and filter (you saw it coming, I know), so people can find what they wanna read.
The essays are a custom post type. There’re also two more CPTs: Collections (to group essays) and Authors.
There are plenty of ACF fields attached to these CPTs, including two relationship fields to link essays to collections and essays to authors. Another important ACF field is the publishing year (as a date picker field).
I’ve managed to create a search form to find essays by author, publishing date or categories, and it’s set up this way:
(general settings — Itens stands for Essays, Coleções for Collections)
(display settings)
Ok, now what’s going on
When I make the first filter (eg.: click an author’s name), I’m redirected to a new page with results. Then, if I click any other author, the results list looks like it’s refining the search, the URL changes, but the results are still the same after the AJAX request. If I manually refresh the page with the 2-author-URL, things work how they are supposed to work: both of authors’ essays are available on results.
What I need to be happening
I searched on docs and tried every option to make things work, but results are not on the same page of search form and the filters are basically not working after the first action.
The ideal scenario would be results on same page of filters and that these work properly.Anyone could help?
Trevor(Private) August 13, 2018 at 12:16 pm #185290From the settings, it looks like the site is on a local install, so I cannot see it working. Is that correct?
From what you describe, it looks like the Ajax Container settings (which is currently set to
#main
I can see from your screenshots) is wrong.#main
is the standard container name for a list of archives results (as per the WordPress Codex), but my guess is your theme uses something else.If I could see the site live, then I could advise you better.
Trevor(Private) August 14, 2018 at 1:15 pm #185468Ok, I have revealed the counts for now and enabled Auto Count (for the counts to work).
Did you add some code so that the ones you select switch to the top of the list?
Can you try this with Ajax off for now? If that works, try it with normal pagination (not infinite scroll).
Anonymous(Private) August 14, 2018 at 1:38 pm #185478Trevor, thank you for the response!
Yes, I added this css so the designer could stay in peace as now he knows this is possible (put selected items on top)
I disabled Ajax and things started to work a little bit more as expected, without Ajax infinite scrolling won’t work, right? Can we make it work with Ajax?
Trevor(Private) August 14, 2018 at 2:36 pm #185497It will be the template code for that page that is causing it not to work, most likely using either query_posts or pre_get_posts, which is overriding our filter. If this is the case, a way around this is to use the Custom display method, described here:
https://searchandfilter.com/documentation/search-results/custom/
Anonymous(Private) August 14, 2018 at 2:56 pm #185503Trevor, you mean the archive.php file?
We use Auttomatic’s Underscores as base, so I believe it’s using the most “stick to the codex” code, right?
In our case, archive.php gives this code between
get_header()
andget_sidebar()
/get_footer()
:<main id="main" class="site-main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_description( '<div class="archive-description">', '</div>' ); ?> </header><!-- .page-header --> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); /* * Include the Post-Type-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Type name) and that will be used instead. */ get_template_part( 'template-parts/content', get_post_type() ); endwhile; the_posts_navigation(); else : get_template_part( 'template-parts/content', 'none' ); endif; ?> </main><!-- #main -->
-
AuthorPosts