Forums › Forums › Search & Filter Pro › Is it possible to start the search form with no results?
Tagged: Checkbox Result
- This topic has 18 replies, 2 voices, and was last updated 7 years, 10 months ago by Trevor.
-
Anonymous(Private) January 5, 2017 at 10:20 am #80206
shure!
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(3552)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo "make your selection"; } else { if ( $query->have_posts() ) { echo "<div class=\"row\">"; while ($query->have_posts()) { $query->the_post(); ?> <div class="col-md-3 popmake-<?php the_ID();?> data-do-default="" style="cursor: pointer;"> <h3 style="text-align: center;"><?php the_title(); ?></h3> <p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p> </div> <?php echo "</div>"; } } else { echo "No Results Found"; } } ?>
Trevor(Private) January 5, 2017 at 10:28 am #80210There were a couple of errors in that, so I have re-coded it (I am not sure about the do_shortcode bit, but I have left that as is):
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(3552)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo "make your selection"; } else { if ( $query->have_posts() ) { echo '<div class="row">'; while ($query->have_posts()) { $query->the_post(); ?> <div class="col-md-3 popmake-<?php the_ID();?>" data-do-default="" style="cursor: pointer;"> <h3 style="text-align: center;"><?php the_title(); ?></h3> <p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p> </div> <?php echo '</div>'; } } else { echo 'No Results Found'; } } ?>
That may make no difference, but give it a try.
Anonymous(Private) January 5, 2017 at 10:48 am #80216Yes, you are right. Your corrections was one forgotten quote (that may be important) and changing the double qoutes at the echos to quotes. I think that’s not necessary at that point. But your correction does not solve the Problem.
Well, the do_shortcode was a test, that also does not solve the problem.Trevor(Private) January 5, 2017 at 11:33 am #80226Something is obviously odd with the way the divi does this. It is the line using the_exceprt() that is the issue. Read these two WP Codex pages:
https://codex.wordpress.org/Function_Reference/get_the_excerpt
https://developer.wordpress.org/reference/functions/the_excerpt/and you will see that shortcodes should actually be removed
Does it look any different if you replace
<p style="text-align: center;"><?php the_excerpt(); ?></p>
with
<p style="text-align: center;"><?php echo get_the_excerpt(); ?></p>
-
AuthorPosts