Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search Search Results for 'found_posts'

Viewing 10 results - 171 through 180 (of 254 total)
  • Author
    Search Results
  • #103846

    Trevor
    Moderator

    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.

    #103732

    Trevor
    Moderator

    The 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";
    }
    ?>
    #102009

    Trevor
    Moderator

    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";
    }
    ?>
    #100516
    [Resolved]

    Topic: Display results – Custom


    Emil Andreis
    Participant

    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(); ?>

    #100241

    Ross
    Keymaster

    Hi 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 / 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:

    (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

    #99956

    Erik Bowie
    Participant

    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

    #99243

    Trevor
    Moderator

    Hi

    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.

    https://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/#Get_labelsfor_Multiple_Fields_by_Field_Name

    I think you should be able to use these examples to make your own code? The last example may be especially helpful.

    #97283

    Emmanuel Anger
    Participant
    This reply has been marked as private.
    #97045

    BAM
    Participant

    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:

    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";
    }
    ?>
    #96787

    BAM
    Participant

    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.

    Development page: http://brushproject.brightartmedia.com

    I have tried to resolve this by editing the results.php myself, without luck. I’d appreciate any help getting this to work better!

    <?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">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="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="sixteencolumns">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";
    }
    ?>

    CSS:

    .last {    
    margin-right: 0 !important;
    }
Viewing 10 results - 171 through 180 (of 254 total)