How 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.
A 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";
}
?>
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 / setup
2) 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:
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.
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:
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.
Hi, 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:
Hi, I have been working on a grid search results.php file to make the results appear consistently during filtering. The search results grid works great until there are more results showing than appear on a single page, requiring pagination. Then the “Older Posts” and “Page 1 of 2” appear inside the grid, and displace the search results.
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookies
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
3rd Party Cookies
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!