Forums › Forums › Search & Filter Pro › Shortcode results: don't display results until click
Tagged: shortcode
- This topic has 20 replies, 3 voices, and was last updated 8 years, 3 months ago by Anonymous.
-
Anonymous(Private) July 19, 2016 at 6:14 pm #51650
Hi – I am using a shortcode form and shortcode results on the same page (two separate columns). I am also using your template results.php file. Right now, as soon as you go to the page, it shows the form, and all entries that are available under results… then, when you click on an option in the form, it starts to actually filter the proper results.
Is it possible to have the results shortcode not actually display any results until the first option is clicked on the form? (I am also using auto submit). I would like the results area to just be blank until someone starts interacting with the search form.
Trevor(Private) July 20, 2016 at 11:00 am #51697This has been asked for before:
https://support.searchandfilter.com/forums/topic/hide-search-results-on-page-load/
https://support.searchandfilter.com/forums/topic/split-hide-search-results-on-page-load/
https://support.searchandfilter.com/forums/topic/how-do-i-hide-initial-results/
I am not sure if they are of any help?
Trevor(Private) July 20, 2016 at 5:18 pm #51732Hi
Sadly the code you posted has gotten mangled by the forum script 🙁
Before the block of code and after it needs to be a code tag. On my screen, above where I am typing this, I can see the formatting buttons (bold, italic etc) and the last but one is the code tag button. Press this once before and once after the code. You will see it actually types a ‘back tick’, if you can see the button bar that is. Otherwise, on my keyboard, the symbols button to the left of the 1 key also types the same back tick.
Can you re-post the results.php code?
Trevor(Private) July 20, 2016 at 5:38 pm #51738Hi
I found two errors (one was ours, one yours), so here is the fixed code (I do not know if this will work):
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ if ( $query->have_posts() ) { global $searchandfilter; $sf_current_query = $searchandfilter->get(44)->current_query(); if ($sf_current_query->is_filtered()) { ?> <?php echo $query->found_posts; ?> Firm(s) Meet All Selected Criteria<br/> <div class="pagination"> <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi(array('query' => $query)); } ?> </div> <?php while ($query->have_posts()) { $query->the_post(); ?> <div> <h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6> <p><?php the_tags(); ?></p> </div> <hr/> <?php } ?> <div class="pagination"> <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></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 "No firms meet all of your criteria. Try unchecking some boxes."; } } ?>
-
AuthorPosts