-
AuthorSearch Results
-
April 26, 2017 at 4:56 pm #105020
In 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 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 results
tab?$query_name->found_posts
is the correct way to grab this, but the$query_name
may 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 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_posts
variable 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.
March 15, 2017 at 2:20 pm #97045In reply to: Grid results display incorrectly with pagination
AnonymousInactiveHi, that was my mistake – I was experimenting with edits to see what effect it would have. I have made the changes you suggested, and it looks like clearfix fixed the starting grid. (Thank you!)
However, when I click on one category, it still shows fewer results, and moves one over. When I refresh the page, the problem is fixed. See the result here:
http://brushproject.brightartmedia.com/wp-content/uploads/2017/03/SearchResults3.jpg
Do you have any suggestions for what has caused this error? Could it be an ajax issue?
Current results.php:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: This template has been modified to link search results * images to artist pages that need to be defined in * Custom Fields in the individual image post. * * The custom field is “artistpage” . * The image in search results will incorporate the link you set * for that custom field. If no link is defined, the image will * not link to an artist page. * * * */ if ( $query->have_posts() ) { ?> <div class="sixteencolumns clearfix">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( 'More Murals', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Recent Murals' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div></div> <?php $column_count = 0; $last_class = ""; while ($query->have_posts()) { $query->the_post(); if ($column_count == 0) echo '<div class="sixteencolumns clearfix">'; ?> <div class="one_fourth<?php echo $last_class;?>"> <?php if ( has_post_thumbnail() ) { ?> <span class="responsive"><a href="<?php echo get_post_meta($query->post->ID,'artistpage',true); ?>"> <?php the_post_thumbnail("small");?></a></span> <?php } ?> </div> <?php $column_count ++; if ($column_count == 4) { $column_count = 0; echo '</div>'; $last_class = ""; } if ($column_count == 3) { $last_class = " last"; } } if ($column_count > 0) echo '</div>'; ?> <div class="sixteencolumns clearfix">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( 'More Murals', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Recent Murals' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div></div> <?php } else { echo "No Results Found"; } ?>
March 9, 2017 at 7:13 pm #95823In reply to: Customize search results
TrevorParticipantHi
Thinking about this some more. In the WordPress Codex:
https://codex.wordpress.org/Plugin_API/Filter_Reference/found_posts
So that should give you what you the count that you want, yes? 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_posts
variable still.If you take a look at this part of our documentation, 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 especially (for you).
March 6, 2017 at 7:17 pm #95003In reply to: Add Custom Field link to thumbnail in results
AnonymousInactiveHi, I took the results.php template from a sample I found in this forum, and it has always given 3 columns instead of 4. You can view the search at the development location here. Here is the entire current results.php:
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: This template has been modified to link search results * images to artist pages that need to be defined in * Custom Fields in the individual image post. * * The custom field is “artistpage” . * The image in search results will incorporate the link you set * for that custom field. If no link is defined, the image will * not link to an artist page. * * * */ if ( $query->have_posts() ) { ?> <div class="sixteen columns">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></div> <?php $column_count = 0; $last_class = ""; while ($query->have_posts()) { $query->the_post(); if ($column_count == 0) echo '<div class="sixteen columns">'; ?> <div class="one_fourth<?php echo $last_class;?>"> <?php if ( has_post_thumbnail() ) { ?> <span class="responsive"><a href="<?php echo get_post_meta($query->post->ID,'artistpage',true); ?>"> <?php the_post_thumbnail("small");?></a></span> <?php } ?> </div> <?php $column_count ++; if ($column_count == 4) { $column_count = 0; echo '</div>'; $last_class = ""; } if ($column_count == 3) { $last_class = " last"; } } if ($column_count > 0) echo '</div>'; ?> <div class="sixteen columns">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> <?php } else { echo "No Results Found"; } ?>
Thank you for your help!
-
AuthorSearch Results