-
Search Results
-
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?
Hey guys,
we have about 50 results in total and 20 per page. The results page shows that there are 3 pages (before applying any filters) which is correct. But you can’t click through them before applying a filter.
Here’s the link to the website:
https://hypnoschool.de/therapeutenliste/uebersichtHeres ist the code fom my 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() ) { ?> <?php echo $query->found_posts; ?> Ergebnisse gefunden<br /> Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></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="therapeut"> <p><a href="<?php the_permalink(); ?>"><?php the_field("name"); ?></a></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("thumbnail"); echo '</p>'; } ?> <p><?php the_field("land"); ?></p> <p><?php the_field("plz_&_stadt"); ?></p> </div> <hr /> <?php } ?> Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></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 "Keine Ergebnisse gefunden"; } ?>