-
AuthorSearch Results
-
April 7, 2017 at 4:40 pm #102009
In 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 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 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!
February 20, 2017 at 4:51 pm #91473
AnonymousInactiveOoops. I tried to create a code box with bbcode but it seems it doesn’t work here. Sorry for that! Here you have it again.
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(21899)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div> </div>'; } else { if ( $query->have_posts() ) { ?> Se han encontrado <strong><?php echo $query->found_posts; ?> resultados</strong><br /> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class='search-filter-results-list'> <a href="<?php the_permalink(); ?>"><h2 class='search-filter-title'><?php the_title(); ?></h2> <?php if ( has_post_thumbnail() ) { echo '<div class="menu-img">'; the_post_thumbnail("full"); echo '</div>'; } ?> </a></div> <?php } ?> <?php } else { echo "No se han encontrado resultados"; } } ?>
February 7, 2017 at 5:04 pm #88565In reply to: Problem with search results
TrevorParticipantIf you followed the customization instructions for the results.php template file, you can edit this to change/remove elements, and their HTML and CSS classes/ID’s, and also add HTML and add other fields or data by adding WordPress PHP.
I have previously posts some examples of edited results.php files. This link is for a search to find these other examples:
https://support.searchandfilter.com/forums/search/Sample+Results+Template/
February 2, 2017 at 5:25 pm #87657In reply to: Force selection?
TrevorParticipantHi Lisa
You can also let them search, but show them nothing (or a custom message) using this type of PHP code (change the number
1234
for the ID number of your search form and change the lineecho '<div>Nothing to see here folks!</div>';
for whatever you want before the filter is used instead of the results – or remove for nothing at all):global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { // your theme template code here for the part that runs the loop, e.g. if ( $query->have_posts() ) ..... }
For example, if you were using the shortcode method. OK, if you have followed the documentation to make a copy of the results.php into a new folder called
search-filter
in your child theme or theme folder, then replace the contents of that template file with 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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { 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> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><br /><?php the_excerpt(); ?></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> <p><?php the_category(); ?></p> <p><?php the_tags(); ?></p> <p><small><?php the_date(); ?></small></p> </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"; } } ?>
January 26, 2017 at 2:55 pm #85731
TrevorParticipantJust in case this happens again, this is the code I wrote:
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(5048)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo ''; } else { 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> <div class="slz-shortcode sc_block_posts "><div class="slz-template-03 "> <div class="slz-list-block slz-column-2"> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="item"> <div class="slz-block-item-01 style-1"> <?php if ( has_post_thumbnail() ) {?> <div class="block-image"> <a href="<?php the_permalink(); ?>" class="link"> <?php the_post_thumbnail("full", array( 'class' => 'img-responsive' ));?> </a> </div> <?php } ?> <div class="block-content"> <div class="block-content-wrapper"> <a class="block-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <ul class="block-info"> <li><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><span class="author-label">By </span><span class="author-text"><?php the_author(); ?></span></a></li> <li><a href="<?php the_permalink(); ?>" class="link date"><?php the_date(); ?></a></li> <li><a href="<?php the_permalink(); ?>#comments" class="link comment"><?php comments_number();?></a></li> <li><a href="<?php the_permalink(); ?>" class="link view">?? Views</a> </li> <li><?php the_category(); ?></li> </ul> <div class="block-text"><?php echo get_the_excerpt(); ?></div> </div> </div> </div> </div> <?php } ?> </div> </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"; } } ?>
January 19, 2017 at 12:01 pm #83677In reply to: How display Result page as Grid ?
TrevorParticipantI have written a new results.php for you:
<?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 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 class="col-9 hb-equal-col-height hb-main-content"> <div id="hb-blog-posts" class="hb-blog-grid masonry-holder clearfix" data-layout-mode="fitRows" data-categories="" data-column-size="col-4"> <?php while ($query->have_posts()) { $query->the_post(); ?> <article id="post-<?php echo get_the_ID();?>" class="col-4 post-<?php echo get_the_ID();?> post type-post status-publish format-standard has-post-thumbnail hentry" itemscope="" itemtype="http://schema.org/BlogPosting"> <div class="featured-image"> <a href="<?php the_permalink(); ?>"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail("small"); ?> <div class="featured-overlay"></div> <div class="item-overlay-text" style="opacity: 0;"> <div class="item-overlay-text-wrap" style="padding-top: 0px;"> <span class="plus-sign"></span> </div> </div> <?php } ?> </a> </div> <div class="post-content"> <div class="post-header"> <h2 class="title" itemprop="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> </div> <p><?php echo get_the_excerpt(); ?> <br /><a href="<?php the_permalink(); ?>" class="read-more">Read More</a> </p> </div> </article> <?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"; } ?>
January 5, 2017 at 10:28 am #80210
TrevorParticipantThere were a couple of errors in that, so I have re-coded it (I am not sure about the do_shortcode bit, but I have left that as is):
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(3552)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo "make your selection"; } else { if ( $query->have_posts() ) { echo '<div class="row">'; while ($query->have_posts()) { $query->the_post(); ?> <div class="col-md-3 popmake-<?php the_ID();?>" data-do-default="" style="cursor: pointer;"> <h3 style="text-align: center;"><?php the_title(); ?></h3> <p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p> </div> <?php echo '</div>'; } } else { echo 'No Results Found'; } } ?>
That may make no difference, but give it a try.
January 5, 2017 at 10:20 am #80206
AnonymousInactiveshure!
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(3552)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo "make your selection"; } else { if ( $query->have_posts() ) { echo "<div class=\"row\">"; while ($query->have_posts()) { $query->the_post(); ?> <div class="col-md-3 popmake-<?php the_ID();?> data-do-default="" style="cursor: pointer;"> <h3 style="text-align: center;"><?php the_title(); ?></h3> <p style="text-align: center;"><?php do_shortcode(the_excerpt()); ?></p> </div> <?php echo "</div>"; } } else { echo "No Results Found"; } } ?>
-
AuthorSearch Results