Looking for support? You can access the support system via your account.
-
Search Results
-
[Resolved]
Topic: Losing JS/HTML format when using AJAX
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"; } ?>