-
Search Results
-
We purchased the Search & Filter Plugin Pro and have it all set up but we want to customize the search results to look like our usual search results – see http://www.farmtocafeteriacanada.ca/?s=school. (You’ll see the Search & Filter tab installed in the right sidebar)
When we set the Display Result to “Shortcode” the template doesn’t reflect our theme and we haven’t been able to figure out how to customize the new results.php file that we moved into our child theme.
When we set the Display Result to “As an Archive” and use our search.php custom template, the filter results don’t update when a new search term combination is entered. Only a manual refresh works. On other posts you have said that “any PHP needs to be inside the Ajax Container, or it will not update” ; “I suspect that the title PHP code is outside the Ajax Container, and thus not being refreshed. In that case, you may need to use a different Ajax Container that does include the title code, OR move the title inside the current Ajax Container.”
Sadly we’re not developers and don’t understand how to make this work. Is there an easy change that we could make in the Ajax Container box? Or some other solution that you’d suggest e.g. using the query code?
Thanks.
Hello again,
we are developing a website, and we are calling results from woocommerce products. All data from posts can be seen on the results page.
However, suddenly, the search and filter fields disappeared. We thought at first it was ACF plugin that we installed, and it was not. It took hours to find out the problem. It is the WooCommerce plugin.
Then we tried to use the default result page. It worked fine!
So we ended up to cut pieces of the code to understand what was wrong. Finally we found a woocoomerce public action:
<?php do_action(‘woocommerce_single_product_summary’); ?>
This is somehow conflicting with the filter, as the content is loaded.
Would you have any idea how go around it?
here is the results.php code:
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
*
* 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 this file is called directly, abort.
if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}if ( $query->have_posts() )
{
?>Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><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();?>
<?php
/**
* This is a reference from WooCommerce to load simple product data
* Hook: woocommerce_single_product_summary.
*
* @hooked woocommerce_template_single_title – 5
* @hooked woocommerce_template_single_rating – 10
* @hooked woocommerce_template_single_price – 10
* @hooked woocommerce_template_single_excerpt – 20
* @hooked woocommerce_template_single_add_to_cart – 30
* @hooked woocommerce_template_single_meta – 40
* @hooked woocommerce_template_single_sharing – 50
* @hooked WC_Structured_Data::generate_product_data() – 60do_action( ‘woocommerce_single_product_summary’ );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_rating’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_excerpt’, 20 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_sharing’, 50 );*/
?><div class=”course”>
<div class=”course-main”>
<div class=”course-image”><?php the_post_thumbnail(“small”); ?></div>
<?php $price = get_post_meta(get_the_ID(), ‘_price’, true); ?>
<div class=”course-price”><?php echo ‘<p class=”price”>£’ . number_format($price, 0, ‘.’, ‘.’) ; ?></div>
<div class=”course-title”><?php the_title(); ?></div>
<div class=”course-plus”>
<div class=”purchase-button-bg”></div>
<div class=”more-info-button-bg”></div>
</div></div>
</div>
<div class=”course-buttons”>
<div class=”course-purchase”>
<div class=”topics”>
<span type=”button” onclick=”PurchaseFront()”>Purchase</span>
<div class=”course-add content-inner”><div class=”course-summary”><?php do_action(‘woocommerce_single_product_summary’); ?></div></div>
</div>
</div>
<div class=”course-more-info”>
<div class=”topics”>
<span type=”button” onclick=”MoreInfoFront()”>More Info +</span>
<div class=”course-full-content content-inner”>
<div class=”tab”>
<input type=”button” value=”Description” title=”course-description-tab” onclick=”openService(event, ‘course-description-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
<input type=”button” value=”Audience” title=”course-audience-tab” onclick=”openService(event, ‘course-audience-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
<input type=”button” value=”Outcomes” title=”course-outcomes-tab” onclick=”openService(event, ‘course-outcomes-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
<input type=”button” value=”Prerequisites” title=”course-prerequisites-tab” onclick=”openService(event, ‘course-prerequisites-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
<input type=”button” value=”Licences” title=”course-licences-tab” onclick=”openService(event, ‘course-licences-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
<input type=”button” value=”Certification” title=”course-certification-tab” onclick=”openService(event, ‘course-certification-<?php echo get_the_ID();?>’)” class=”tab-layout tablinks” />
</div>
<div id=”course-description-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo the_content(get_the_ID(), ”, true); ?></div>
<div id=”course-audience-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘audience-shop’, true); ?></div>
<div id=”course-outcomes-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘outcomes-shop’, true); ?></div>
<div id=”course-prerequisites-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘prerequisites-shop’, true); ?></div>
<div id=”course-licences-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘licences-shop’, true); ?></div>
<div id=”course-certification-<?php echo get_the_ID()?>” class=”tabcontent” style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘certification-shop’, true); ?></div>
</div>
</div>
</div>
</div><hr />
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><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
}
else
{
echo “No Results Found”;
}
?>Hello,
we have some JS scripts on a results page.
Here is the page: http://gtssolutionscic-com.stackstaging.com/courses-test/
In the collapsible “More info+”, we have a series of tabs that should work like this: http://gtssolutionscic-com.stackstaging.com/services/
The unique code (custom-tabs-products.js) for the tab:
function openGoal(evt, devGoals) {
var i, tabcontent2, tablinks2;
tabcontent2 = document.getElementsByClassName(“tabcontent3”);
for (i = 0; i < tabcontent2.length; i++) {
tabcontent2[i].style.display = “none”;
}
tablinks2 = document.getElementsByClassName(“tablinks3″);
for (i = 0; i < tablinks2.length; i++) {
tablinks2[i].className = tablinks2[i].className.replace(” active3″, “”);
}
document.getElementById(devGoals).style.display = “block”;
evt.currentTarget.className += ” active3″;
}To work with this “results.php”:
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link https://searchandfilter.com
* @copyright 2018 Search & Filter
*
* 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 this file is called directly, abort.
if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}if ( $query->have_posts() )
{
?>Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><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 class=”course”>
<div class=”course-main”>
<div class=”course-image”><?php the_post_thumbnail(“small”); ?></div>
<?php $price = get_post_meta(get_the_ID(), ‘_price’, true); ?>
<div class=”course-price”><?php echo ‘<p class=”price”>£’ . number_format($price, 0, ‘.’, ‘.’) ; ?></div>
<div class=”course-title”><?php the_title(); ?></div>
<div class=”course-plus”>
<div class=”purchase-button-bg”></div>
<div class=”more-info-button-bg”></div>
</div></div>
</div>
<div class=”course-buttons”>
<div class=”course-purchase”>
<div class=”topics”>
<span>Purchase</span>
<div class=”course-add content-inner”><div class=”course-summary”><?php do_action( ‘woocommerce_single_product_summary’ ); ?></div></div>
</div>
</div>
<div class=”course-more-info”>
<div class=”topics”>
<span>More Info +</span>
<div class=”course-full-content content-inner”>
<div class=”tab”>
<button title=”course-description-tab” onclick=”openService(event, ‘course-description’)” class=”tab-layout tablinks3″ /><span>Description</span></button>
<button title=”course-audience-tab” onclick=”openService(event, ‘course-audience’)” class=”tab-layout tablinks3″ /><span>Audience</span></button>
<button title=”course-outcomes-tab” onclick=”openService(event, ‘course-outcomes’)” class=”tab-layout tablinks3″ /><span>Outcomes</span></button>
<button title=”course-prerequisites-tab” onclick=”openService(event, ‘course-prerequisites’)” class=”tab-layout tablinks3″ /><span>Prerequisites</span></button>
<button title=”course-licences-tab” onclick=”openService(event, ‘course-licences’)” class=”tab-layout tablinks3″ /><span>Licences</span></button>
<button title=”course-certification-tab” onclick=”openService(event, ‘course-certification’)” class=”tab-layout tablinks3″ /><span>Certification</span></button>
</div>
<div id=”course-description” class=”tabcontent3″ style=”display: block;”><?php the_content(); ?></div>
<div id=”course-audience” class=”tabcontent3″ style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘Audience’, true); ?></div>
<div id=”course-outcomes” class=”tabcontent3″ style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘Outcomes’, true); ?></div>
<div id=”course-prerequisites” class=”tabcontent3″ style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘Prerequisites’, true); ?></div>
<div id=”course-licences” class=”tabcontent3″ style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘Licences’, true); ?></div>
<div id=”course-certification” class=”tabcontent3″ style=”display: block;”><?php echo get_post_meta(get_the_ID(), ‘Certification’, true); ?></div>
</div>
</div>
</div>
</div><?php
/**
* This is a reference from WooCommerce to load simple product data
* Hook: woocommerce_single_product_summary.
*
* @hooked woocommerce_template_single_title – 5
* @hooked woocommerce_template_single_rating – 10
* @hooked woocommerce_template_single_price – 10
* @hooked woocommerce_template_single_excerpt – 20
* @hooked woocommerce_template_single_add_to_cart – 30
* @hooked woocommerce_template_single_meta – 40
* @hooked woocommerce_template_single_sharing – 50
* @hooked WC_Structured_Data::generate_product_data() – 60do_action( ‘woocommerce_single_product_summary’ );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_rating’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_excerpt’, 20 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_sharing’, 50 );*/
?><hr />
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><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
}
else
{
echo “No Results Found”;
}
?>Besides the tab does not work on the results page, when we use the ajax price filter, for instance, the tab loses its style, putting the <span> outside the <button>
<button title=”course-outcomes-tab” onclick=”openService(event, ‘course-outcomes’)” class=”tab-layout tablinks3″></button>
<span>Outcomes</span>Would you have any ideas how to fix it?
Hi, I’m trying to display all custom posts separated by custom taxonomy term.
Format:
<h2>Term 1</h2>
{All posts from taxonomy term 1}<h2>Term 2</h2>
{All posts from taxonomy term 2}Can you tell me how to incorporate this into the loop in results.php?
I saw some documentation saying add $args[‘search_filter_id’] = 123 but not sure.
Thank you! (my loop below)$patient_story_types = get_terms('patient_story_type'); foreach($patient_story_types as $patient_story_type) : wp_reset_query(); $patient_story_args = array( 'post_type' => 'patient_story', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'patient_story_type', 'field' => 'slug', 'terms' => $patient_story_type->slug, ), array( 'taxonomy' => 'patient_story_type', 'terms' => array('featured'), 'field' => 'slug', 'operator' => 'NOT IN', ), ), ); $custom_query = new WP_Query($patient_story_args); if($custom_query->have_posts()) : ?> <h3 class="patient-story-type"><?php echo $patient_story_type->name; ?></h3> <div class="patient-stories"> <?php while($custom_query->have_posts()) : $custom_query->the_post(); ?> <div class="patient-story"> <div class="card"> <?php if(has_post_thumbnail()) { ?> <a>"><?php the_post_thumbnail('large', array('class'=>'img-responsive aligncenter', 'alt'=>get_the_title(), 'title'=>get_the_title())); ?></a> <?php } ?> <div class="card-body"> <?php $patient_story_type_terms = get_the_terms($post->ID, 'patient_story_type'); ?> <h4<?php if($patient_story_type_terms) { echo ' class="has-terms"'; } ?>><a>"><?php the_title(); ?></a></h4> <?php if($patient_story_type_terms) { echo "<ul class='list-inline patient-story-type-terms'>"; foreach($patient_story_type_terms as $patient_story_type_term) { echo "<li>". $patient_story_type_term->name ."</li>"; } echo "</ul>"; } ?> <p><?php pva_custom_excerpt(array('length' => 25, 'suffix' => '…', 'link_text' => '')); ?></p> <p><a>">Read Full Story</a></p> </div><!-- .card-body --> </div><!-- .card --> </div><!-- .patient-story --> <?php endwhile; ?> </div><!-- .patient-stories --> <?php endif; endforeach; ?>