Forums › Forums › Search & Filter Pro › Display results using The Grid plugin as template
Tagged: archive, display results, Grid plugin
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by Trevor.
-
Anonymous(Private) October 10, 2019 at 10:28 am #223369
Hello Trevor,
I use The Grid plugin to display my posts. I would also want to use it to display S&F results: : https://theme-one.com/docs/the-grid/#grid_as_template
So far I have been using this file (named taxonomy.php) to display S&F posts:
<?php /** * The template for displaying archive pages. * * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package Milkit */ get_header(); ?> <?php echo do_shortcode('[searchandfilter id="32129"]');?> <?php echo milkit_breadcrumbs(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?> </header><!-- .page-header --> <div class="post-modules"> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-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 Format name) and that will be used instead. */ get_template_part( 'content', 'taxonomy' ); ?> <?php endwhile; ?> </div><!-- .post-modules --> <?php milkit_paging_nav(); ?> <?php else : ?> <?php get_template_part( 'content', 'taxonomy' ); ?> <?php endif; ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar( 'blog' ); ?> <?php get_footer(); ?>
I used The Grid plugin documentation to create a new file taxonomy_new.php : https://theme-one.com/docs/the-grid/#grid_as_template
Here it what it looks like:
<?php /** * The template for displaying archive pages. * * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package Milkit */ get_header(); ?> <?php echo milkit_breadcrumbs(); ?> <?php echo do_shortcode('[searchandfilter id="32129"]');?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <header class="page-header"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?> </header><!-- .page-header --> <?php The_Grid('Posts_archive', true); // where true is for template mode if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php endwhile; ?> <?php endif; ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar( 'blog' ); ?> <?php get_footer(); ?>
It doesn’t really works. The Grid is correctly used on a first search on my test website. But if I modifiy the search filters there appears the problem the grid images are not loaded, only some post terms.
Please let me knwow if this isn’t clear and if you need additional information.
Trevor(Private) October 10, 2019 at 5:16 pm #223406Ajax results refreshing is quite hard to set up. Does it work OK with Ajajx OFF?
Which display Results method are you using, and is the template being applied to a specific page (as many of our Display Results Methods need to use a defined results URL), as I was thinking whether it might work in Custom mode, with this extra shortcode:
echo do_shortcode('[searchandfilter id="32129" action="filter_next_query"]');
Placed just before this line:
The_Grid('Posts_archive', true)
Anonymous(Private) October 11, 2019 at 12:01 pm #223444Thanks Trevor,
Turning AJAX off solves the issue.
What am I losing by turning it off? The pagination function? (it is not much of a big deal as searches do not display that many results on my website).
To answer your question I am using the Archive Mode to display results.
For your information (and to improve my knowledge) I tried to implement your suggestion in Custom Mode.
I created a Searches page which I based upon a new page-searches.php template containing the following code:
<?php /* Template Name: page-searches */ get_header(); ?> <main id="main" class="site-main single-page" role="main"> <?php echo do_shortcode('[searchandfilter id="32129" action="filter_next_query"]'); The_Grid('Posts_archive', true); // where true is for template mode if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php endwhile; ?> <?php endif; ?> </main><!-- #main --> <?php get_footer(); ?>
I then linked the S&F form to this Searches page url. But when I do a search with this S&F form the Searches page does not display any post (same when I try to use the standard loop of my theme, not The Grid shortcode).
Is there something I didn’t understand about Custom Mode?
Thanks.
Nicolas
Trevor(Private) October 11, 2019 at 5:49 pm #223497Not at all. The Custom mode tends to get used when all else fails, usually (as in your case) when some non-standard code is being used to create the ‘results grid’. If you had been lucky, it would have worked as specified, but it did not. What you lose keeping it as it was, but with Ajax OFF, is the page will reload between searches, rather than just the results fading in and out.
-
AuthorPosts