-
AuthorSearch Results
-
April 26, 2017 at 6:27 pm #105029
In reply to: Results count… can't make it work
AnonymousInactiveTrevor I don’t understand your question.
I actually got $total_results = $query->found_posts; and echo $total_results.If you ask for Search&Filter form options in “display results tab” I got this:
Results URL: http://stude.masterbip.com/test/
Load results using Ajax? YES
Make searches bookmarkable? YES
Only use Ajax on the results page? NO
Scroll window to: none
Ajax Container: #propresults
Pagination Type: Normal
Pagination selector: .paginacion ul li a
Show loading icon? YESI can give you admin credentials if you want. Many thanks!
I think all is working but that results counter…
Thanks again in advance!
April 26, 2017 at 4:56 pm #105020In reply to: Results count… can't make it work
TrevorParticipantI fixed the code to show as code.
I see. You have a variable
$total_results. You set this like this:$total_results = $query->found_posts;What Display Result method are you using in the form?
April 26, 2017 at 4:39 pm #105016In reply to: Results count… can't make it work
AnonymousInactiveMany thanks. No it is not. We design and program themes from scratch.
This is the whole code<?php /* Template name: Buscador de Propiedades */ get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <div class="encabezado page-encabezado buscadorinmueble-encabezado" style="background-image:url( <?php if ( has_post_thumbnail()) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'encabezado' ); $url = $thumb['0']; echo $url; } else{ echo of_get_option('mb_page_encabezado_fondo'); } ?> );"> <div class="grid grid-pad"> <div class="col-1-1 mobile-col-1-1"> <h1 class="text-center"><?php the_title();?></h1> </div> </div> </div> <?php endwhile; ?> <section> <div class="section prop-filtro"> <div class="grid grid-pad"> <div class="col-1-1 mobile-col-1-1"> <div id="prop_buscador_show_wrap" style="display:none;"> <a href="void(0);"><?php _e('Mostrar Filtros','weyketing'); ?></a> </div> <div id="prop_buscador_referencia" class="prop-buscador" style=""> <?php get_template_part( 'propid', 'searchform' ); ?> </div> <div id="prop_buscador" class="prop-buscador prop-buscador-grande activado" style=""> <?php echo do_shortcode(of_get_option('mb_prop_buscador_form')); ?> <a href="void(0);"><?php _e('Mas Filtros','weyketing'); ?></a> <a href="void(0);"><?php _e('Menos Filtros','weyketing'); ?></a> </div> </div> </div> </div> <div class="section prop-featured"> <h2 class="titulo titulo-h2" style="text-align:center;"><span><?php _e('PROPIEDADES DESTACADAS','weyketing');?></span></h2> <div class="clear"></div> <div class="prop-featured-slider"> <?php $args = array( 'post_type' => 'propiedad', 'posts_per_page' => 5, 'order' => 'DESC', 'orderby' => 'date', 'meta_key' => '_featured', 'meta_value' => 'yes' ); query_posts( $args ); $contador = 1; if ( have_posts() ) { while ( have_posts() ) { the_post(); if ( has_post_thumbnail()) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'propiedad-slider' ); $url = $thumb['0']; } else { $url = of_get_option('mb_prop_thumb_default'); } global $propiedad_mb; $propiedad_mb->the_meta(); $prop_id = $propiedad_mb->get_the_value('referencia'); $prop_precio = $propiedad_mb->get_the_value('precio'); $prop_detalle_area_util = $propiedad_mb->get_the_value('area_util'); $prop_detalle_habitaciones = $propiedad_mb->get_the_value('habitaciones'); $prop_detalle_banos = $propiedad_mb->get_the_value('banos'); $prop_detalle_aparcamiento = $propiedad_mb->get_the_value('aparcamiento'); ?> <!-- REPEATER --> <div class="prop-feat-slider-item"> <img />" alt="<?php the_title(); ?>"/> <div class="prop-feat-slider-content"> <div class="grid grid-pad "> <div class="col-8-12 mobile-col-1-1 propiedad-titulo"> <h2><?php the_title(); ?></h2> <p> <?php _e('REF.','weyketing'); echo ' '.$prop_id;?> | <span> <?php $tipos = wp_get_post_terms($post->ID, 'tipo-operacion', array("fields" => "all")); foreach($tipos as $tipo) { echo $tipo->name; } ?> </span> </p> </div> <div class="col-4-12 mobile-col-1-1 propiedad-precio"> <p><strong><?php echo number_format($prop_precio,0,',','.'); ?></strong><span>€</span></p> </div> </div> <div class="grid grid-pad"> <div class="col-9-12 mobile-col-1-1"> <ul class="prop-caract-principales"> <li class="prop-caract"> <img />"/> <?php _e('AREA UTIL','weyketing'); ?><br> <strong><?php echo $prop_detalle_area_util;?> M<sup>2</sup></strong> </li> <li class="prop-caract"> <img />"/> <?php _e('HABITACIONES','weyketing'); ?><br> <strong><?php echo $prop_detalle_habitaciones;?></strong> </li> <li class="prop-caract"> <img />"/> <?php _e('BANOS','weyketing'); ?><br> <strong><?php echo $prop_detalle_banos;?></strong> </li> <li class="prop-caract"> <img />"/> <?php _e('APARCAMIENTO','weyketing'); ?><br> <strong><?php echo $prop_detalle_aparcamiento;?></strong> </li> </ul> </div> <div class="col-3-12 mobile-col-1-1 text-right"> <a>" class="boton" title="<?php _e('Ver: ','weyketing').' '.the_title(); ?>"><?php _e('VER MAS','weyketing'); ?> ></a> </div> </div> </div> </div> <!-- // REPEATER --> <?php $contador = $contador + 1; } // end while } // end if wp_reset_postdata(); ?> </div> <script> jQuery(document).ready(function($){ $('.prop-featured-slider').slick({ adaptiveHeight: true, autoplay: true, infinite:true, autoplaySpeed: 7000, dots: true, fade:true, centerMode: true, }); }); </script> <div class="clear" style="height:70px;"></div> </div> <!-- RESULTADOS DE BUSQUEDA --> <div class="section prop-resultados"> <div class="grid grid-pad"> <?php $args = array('post_type' => 'propiedad'); $args['search_filter_id'] = 355; query_posts( $args ); $contador = 1; ?> <div class="resultados-top"> <div class="col-1-2 mobile-col-1-1"> <?php $total_results = $query->found_posts; echo '<strong>'.__('RESULTADOS DE BUSQUEDA:','weyketing').'</strong> '.$total_results.' '.__('INMUEBLES','weyketing'); ?> </div> <div class="col-1-2 mobile-col-1-1 text-right"> <a href="history.back(-1);"><img />/inc/imagenes/iconos/btn-volver.png"/> <?php _e('VOLVER','weyketing'); ?></a> </div> </div> <div class="col-1-1 mobile-col-1-1"> <ul id="propresults" class="prop-items"> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); if ( has_post_thumbnail()) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'propiedad-thumb' ); $url = $thumb['0']; } else { $url = of_get_option('mb_prop_thumb_default'); } global $propiedad_mb; $propiedad_mb->the_meta(); $prop_id = $propiedad_mb->get_the_value('referencia'); $prop_precio = $propiedad_mb->get_the_value('precio'); $prop_detalle_area_total = $propiedad_mb->get_the_value('area_total'); $prop_detalle_habitaciones = $propiedad_mb->get_the_value('habitaciones'); $prop_detalle_banos = $propiedad_mb->get_the_value('banos'); $prop_detalle_aparcamiento = $propiedad_mb->get_the_value('aparcamiento'); ?> <!-- REPEATER --> <li id="propiedad_<?php the_ID(); ?>" class="prop-item prop-item-0<?php echo $contador; ?>"> <div class="flip-container" ontouchstart="this.classList.toggle('hover');"> <div class="flipper"> <div class="prop-front"> <div class="front-arriba"> <div class="grid grid-pad"> <div class="col-1-1"> <h2><a>" title="<?php _e('Ver: ','weyketing').' '.the_title(); ?>"><?php the_title(); ?></a></h2> </div> <div class="col-1-2"> <p> <small><?php _e('REF.','weyketing'); echo ' '.$prop_id; ?></small> <strong><?php echo number_format($prop_precio,0,',','.'); ?></strong><span>€</span> </p> </div> <div class="col-1-2"> <?php $tipos = wp_get_post_terms($post->ID, 'tipo-operacion', array("fields" => "all")); foreach($tipos as $tipo) { echo '<span class="prop-tipo">'.$tipo->name.'</span>'; } ?> </div> </div> </div> <div class="front-abajo"> <a>" title="<?php _e('Ver: ','weyketing').' '.the_title(); ?>"><img />" alt="<?php the_title(); ?>" class=""/></a> </div> </div> <div class="prop-back"> <div class="back-arriba"> <div class="grid grid-pad"> <div class="col-1-1"> <h2><a>" title="<?php _e('Ver: ','weyketing').' '.the_title(); ?>"><?php the_title(); ?></a></h2> </div> <div class="col-1-2"> <p> <small><?php _e('REF.','weyketing'); echo ' '.$prop_id; ?></small> <strong><?php echo number_format($prop_precio,0,',','.'); ?></strong><span>€</span> </p> </div> <div class="col-1-2"> <?php $tipos = wp_get_post_terms($post->ID, 'tipo-operacion', array("fields" => "all")); foreach($tipos as $tipo) { echo '<span class="prop-tipo">'.$tipo->name.'</span>'; } ?> </div> </div> </div> <div class="back-abajo"> <div class="prop-caracteristicas"> <div class="grid grid-pad"> <div class="col-1-2"> <div class="prop-caract"> <img />"/> <?php _e('AREA UTIL','weyketing'); ?><br> <strong><?php echo $prop_detalle_area_util;?> M<sup>2</sup></strong> </div> </div> <div class="col-1-2"> <div class="prop-caract"> <img />"/> <?php _e('HABITACIONES','weyketing'); ?><br> <strong><?php echo $prop_detalle_habitaciones;?></strong> </div> </div> <div class="col-1-2"> <div class="prop-caract"> <img />"/> <?php _e('BANOS','weyketing'); ?><br> <strong><?php echo $prop_detalle_banos;?></strong> </div> </div> <div class="col-1-2"> <div class="prop-caract"> <img />"/> <?php _e('APARCAMIENTO','weyketing'); ?><br> <strong><?php echo $prop_detalle_aparcamiento;?></strong> </div> </div> </div> </div> <a>" class="boton" title="<?php _e('Ver: ','weyketing').' '.the_title(); ?>"><?php _e('VER MAS','weyketing'); ?></a> </div> </div> </div> </div> </li> <!-- //REPEATER --> <?php $contador = $contador + 1; } // end while ?> <?php navegacion_numerica(); ?> <?php } // end if wp_reset_postdata(); ?> </ul> <div class="clear"></div> </div> </div> </div> </section> <?php get_footer(); ?>April 19, 2017 at 5:09 pm #103846In reply to: Way to show other posts if results are less than X
TrevorParticipantHow do you limit it to 3 results, or do you know that will be the maximum? Whenever a post query is run in WordPress, it makes available to total results count (
found_posts), so you could use this to decided what else to add. The Codex page is here.April 19, 2017 at 11:58 am #103732In reply to: Ajax and Search Filter Pro
TrevorParticipantThe grid I made using our results.php for Enfold was this:
<?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() ) { $gridTotalPostCount = $query->found_posts; ?> Found <?php echo $gridTotalPostCount; ?> 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> <div data-autoplay="" data-interval="5" data-animation="fade" data-show_slide_delay="90" class="avia-content-slider avia-content-grid-active avia-content-slider1 avia-content-slider-odd avia-builder-el-2 el_after_av_textblock avia-builder-el-last " itemscope="itemscope" itemtype="https://schema.org/Blog"> <div class="avia-content-slider-inner"> <?php $gridRowPostCount = 1; while ($query->have_posts()) { $query->the_post(); if ( $gridRowPostCount == 1 ) {?> <div class="slide-entry-wrap"> <?php } ?> <article class="flex_column av_one_third <?php if ( $gridRowPostCount == 1 ) echo 'first';?>" itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost"> <?php if ( has_post_thumbnail() ) { ?><a data-rel="slide-1" class="slide-image" title="" href="<?php the_permalink(); ?>"><?php the_post_thumbnail("portfolio"); echo '</a>'; } ?> <h3 class="slide-entry-title entry-title" itemprop="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <div class="slide-meta"><time class="slide-meta-time updated" itemprop="datePublished"><?php the_date(); ?></time></div> </article> <?php if ( ( $gridRowPostCount == 3 ) || ( $gridRowPostCount == $gridTotalPostCount ) ) {?> </div> <?php } $gridRowPostCount++; if ( $gridRowPostCount == 4 ) $gridRowPostCount = 1; ?> <?php } ?> </div></div> 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"; } ?>April 7, 2017 at 4:40 pm #102009In reply to: Output ACF Post Object fields in results
TrevorParticipantA lot of that you don’t need. You need to be careful of the type of field you are getting. For example, arrays are different. The ACF online manual is a big help. Below is an example results.php file that gets ACF fields and uses them:
<?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() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div style="width:100%;"> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="result"> <?php if (get_field('property_main_image') != '') { ?> <img />" alt="" width="400px" /> <div class="status"><?php echo get_field('status'); ?></div> <div class="details"> <?php echo '<h4>$' . get_field('price') . ' </h4>'; echo '<p>' . get_field('address') . '<br>'; echo get_field('city') . ', '; echo get_field('state'); echo get_field('zip') . '</p>'; echo '<p class="spex">' . get_field('bedrooms') . ' BEDROOMS | '; echo get_field('bathrooms') . ' BATHROOMS<br>'; echo '<span class="secondline">' . get_field('square_footage') . ' SQ FT | '; echo get_field('garages') . ' CAR GARAGE</span>'; echo '<span>MLS# ' . get_field('MLS') . '</span></p>';?> <div class="linx"> <a href="#"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Photos_Grey.png" alt="see photo gallery" /></a> <a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_MapPin_Grey.png" alt="google map for location" /></a> <a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Collateral_Grey.png" alt="brochure download" /></a> </div><!--end linx--> <a>"><img src="/CreativeHomes/wp-content/uploads/2016/08/details-button.png" width="122" alt="details" /></a> </div><!--end details--> <div class="interact"> <span><?php the_favorites_button($post_id, $site_id); ?></span> <span><img src="/CreativeHomes/wp-content/uploads/2016/08/check-icon.jpg" />Compare</span> <span><?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>Share</span> </div><!--end interact--> </div><!--end result--> <?php } ?> </div> <?php } else { echo "No Results Found"; } ?>March 30, 2017 at 8:10 pm #100516Topic: Display results – Custom
in forum Search & Filter Pro
AnonymousInactiveIs there any way to implement custom method to bottom code?
The code is working nice as a template for “display as an archive” option on this page:
http://www.korcula-larus.com/korcula-apartments-map/The problem is that Transposh plugin doesn’t want to translate Search and Filter archive page so I want to set up a filter with a custom method.
<?php
/* Template Name: Larus Map Filter */
/* The template for displaying the custom search results page.
*
* @package WordPress
* @subpackage BookYourTravel
* @since Book Your Travel 1.0
*/
get_header(‘mapfilter’);
//byt_breadcrumbs();
//get_sidebar(‘under-header’);
?><div class=”mapfilter clearfix”>
<?php echo do_shortcode( ‘[searchandfilter id=”20515″]’); ?>
</div>
<section class=”results”>
<div class=”viewnav clearfix”><span class=”resultstats”><?php if (have_posts()) { echo $wp_query->found_posts; _e(‘ Results’, ‘bookyourtravel’); } else { _e(‘No results, please clear all filters and try again.’, ‘bookyourtravel’); } ?></span><span class=”viewswitch”>“><?php echo _e(‘List View’, ‘bookyourtravel’); ?>/listview-icon-02.png” /></span>
</div>
<div class=”mymap_layout”>
<?php echo do_shortcode( ‘[mashup width=”100%” height=”380″ poiList=”false” poiZoom=”17″ draggable=”true”]’); ?>
</div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!–post–><!–//post–>
<?php endwhile;?>
<?php endif; ?>
</section>
<?php get_footer(); ?>March 29, 2017 at 6:43 pm #100241In reply to: Update total results count after ajax
RossKeymasterHi Erik
Ok so lets roll it back a second.
1) What display method are you using in the
display resultstab?$query_name->found_postsis the correct way to grab this, but the$query_namemay vary depending on your display method / setup2) The ajax events – to get this working did you try to wrap them in a function like the last example in the FAQs? Thats usually the issue as you may be hooking into the events too early (when jQuery or S&F has not yet init), try:
(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("S&F ajax finished"); }); }(jQuery));Let me know how you get on and if you can supply a URL to see where you’ve got to that would really help.
Best
March 28, 2017 at 5:03 pm #99956Topic: Update total results count after ajax
in forum Search & Filter Pro
AnonymousInactiveI’ve been searching thru documentation to find either a jquery method or some other way to update the total # of results counter returned the user when the results are updated via ajax.
The results count works correctly on initialization b/c it’s using the original PHP $wp_query->found_posts but after the user interacts with the form and filters, I don’t have a way to update the returned results count.
I’ve been looking thru the docs for hours and can’t find how to do this.
Ex: 40 results found -> 23 results found
March 24, 2017 at 1:18 pm #99243In reply to: Display the request on result
TrevorParticipantHi
It is not a simple thing to do (I think for our next major version, V3, we will make it so), but it is possible, with some coding. You can get the count (xxx results found) and also what fields are set to filter and with what terms, using PHP.
In the WordPress Codex you can find the count code:
https://codex.wordpress.org/Plugin_API/Filter_Reference/found_posts
So that should give you what you the count. In a standard WordPress query, the query array is $wp_query, but your theme may have a customised version, but it should have the
found_postsvariable still.… and to the search terms …
If you take a look at this part of our documentation, our developer, Ross, has added some examples that you could use to get the search terms in the fields/taxonomies.
I think you should be able to use these examples to make your own code? The last example may be especially helpful.
-
AuthorSearch Results
Search Results for 'found_posts'
-
Search Results
-
Topic: Display results – Custom
Is there any way to implement custom method to bottom code?
The code is working nice as a template for “display as an archive” option on this page:
http://www.korcula-larus.com/korcula-apartments-map/The problem is that Transposh plugin doesn’t want to translate Search and Filter archive page so I want to set up a filter with a custom method.
<?php
/* Template Name: Larus Map Filter */
/* The template for displaying the custom search results page.
*
* @package WordPress
* @subpackage BookYourTravel
* @since Book Your Travel 1.0
*/
get_header(‘mapfilter’);
//byt_breadcrumbs();
//get_sidebar(‘under-header’);
?><div class=”mapfilter clearfix”>
<?php echo do_shortcode( ‘[searchandfilter id=”20515″]’); ?>
</div>
<section class=”results”>
<div class=”viewnav clearfix”><span class=”resultstats”><?php if (have_posts()) { echo $wp_query->found_posts; _e(‘ Results’, ‘bookyourtravel’); } else { _e(‘No results, please clear all filters and try again.’, ‘bookyourtravel’); } ?></span><span class=”viewswitch”>“><?php echo _e(‘List View’, ‘bookyourtravel’); ?>/listview-icon-02.png” /></span>
</div>
<div class=”mymap_layout”>
<?php echo do_shortcode( ‘[mashup width=”100%” height=”380″ poiList=”false” poiZoom=”17″ draggable=”true”]’); ?>
</div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!–post–><!–//post–>
<?php endwhile;?>
<?php endif; ?>
</section>
<?php get_footer(); ?>I’ve been searching thru documentation to find either a jquery method or some other way to update the total # of results counter returned the user when the results are updated via ajax.
The results count works correctly on initialization b/c it’s using the original PHP $wp_query->found_posts but after the user interacts with the form and filters, I don’t have a way to update the returned results count.
I’ve been looking thru the docs for hours and can’t find how to do this.
Ex: 40 results found -> 23 results found