Support Forums

Support Forums Forums Search Search Results for 'found_posts'

Viewing 10 results - 21 through 30 (of 200 total)
  • Author
    Search Results
  • #218449

    Trevor
    Moderator

    You are using the ‘As an Archive’ method, and so will have specified the template to use for the results, which will be a theme template (often either search.php or archive.php, but your setup may be different).

    You need to edit that file (or make a re-named copy and use that, preferably in a child theme) and add the PHP code needed to display the message you require. Note that, it should be placed INSIDE the Ajax container you are using, otherwise it will not update when Ajax searches are made.

    I do not know what the array variable that your theme uses for the results, but in this example I have assumed this to be $query, but in your theme it could well be different, so do check your theme code if it does not work and edit my code snippet accordingly):

    <div class="results-found">Found <?php echo $query->found_posts; ?> Results</div>


    Jesse Rosenfield
    Participant

    https://wtg.wpengine.com/the-library/

    Works just fine.

    If you select any filter from the drop down (try content types > blog posts for example). Then remove that filter, it returns to https://wtg.wpengine.com/the-library however there are no results.

    I’ve noticed that this page also yields no results:
    https://wtg.wpengine.com/?sfid=5958&sf_action=get_data&sf_data=all

    Here’s my results page (I’m using some javascript templating and converting the $query results to a JSON array to render the HTML)… so searching for “var libCardJson” in the source code will show you the results (on the page in question libCardJson is ‘[ ]’… i.e. an empty array).

    Additionally using pagination from the initial results page does the same thing (no results).

    Adding multiple filters and removing one at a time does not cause the same issue (only when you clear the last filter and return to the initial results page).

    Any insight or just some more info on how to trouble shoot this would be much appreciated!

    Thanks!

    <?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
     *
     */
    
    ?>
    
    <?php
    
    	global $paged;
    	global $wp_query;
    	global $templateid;
    	global $term_name;
    	
    	$blogid = 5961;
    	
    	$templateid = '';
    	
    	if(is_home() && empty($_GET)) {
    		$templateid = $blogid;
    	} elseif(is_tax()) {
    		$templateid = 'term_' . get_queried_object_id();
    	}	
    ?>
    
    <!-- <button data-toggle="modal" data-target="#filters-modal">Filters Modal</button> -->
    <?php include(realpath(dirname(__FILE__)). '/../templates/lib/lib-single-tax.php'); ?>
    
    <?php if( is_library_ajax() ) : ?>
    	
    	<script id="lib-results-meta-data">
    		
    		var totalresults = <?php echo $query->found_posts; ?>;
    				
    	<?php if($query->found_posts >= 1 && $query->query['paged'] > 0) { ?>
    		var pagedtext = "Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />";
    	<?php } ?>
    	
    	</script>
    	
    <?php endif; ?>
    
    <div id="results-meta-wrap<?php if( is_library_ajax() ) { echo '-ajax'; } ?>"<?php if( is_library_ajax() ) { echo ' class="none"'; } ?>>
    	<?php include(realpath(dirname(__FILE__)) . '/../templates/lib/lib-search.php'); ?>
    
    			<div class="bg-bggray lib-filter--sort-wrap">
    				<div class="container-fluid">
    					
    					<?php if( !is_library_ajax() ) : ?>
    							
    					<div class="group pr lib-filter--sort-container">
    						<div class="fl mbh small-caps lib-filter--total-wrap">
    							<span id="lib-results--total">Found <?php echo $query->found_posts; ?> Results</span>
    							&nbsp; <span class="c-graytext small-caps"<?php if($query->found_posts == 0) { echo ' style="display:none"'; } ?> id="lib-results--paging-title">Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></span>
    						</div>
    						
    						<div class="fr-1200 lib-filter--options">
    							<div class="tar tal-1200 lib-filter--options-label small-caps">
    								<span class="none inline-block-1200">View Options</span>
    								<span class="none-1200">&nbsp;</span>
    							</div>
    							
    							<div class="inline-block mbh">
    								<button id="grid-view" class="selected icon-grid inline-block" title="Grid View"></button>
    								<button id="list-view" class="icon-list inline-block" title="List View"></button>
    							</div>
    							
    							<select id="lib-filter--sort" title="">			
    								<option>Sort Results By</option>
    							</select>
    				
    							<select id="lib-filter--ppp" title="">
    								<option>Posts Per Page</option>
    							</select>			
    						</div>
    					</div>
    					<?php endif; ?>
    					
    					<div class="lib-results--filters-wrap"<?php if( is_library_ajax() ) { echo ' id="lib-results--ajax-filters"'; } ?>>
    						<?php getFilterLinks(); ?>
    					</div>
    				</div>
    			</div>
    
    </div>
    
    <div class="container-fluid mt6">
    	
    	<div role="main">
    		<section class="" id="filter-results">
    
    			<div class="lib-card--wrap grid-3-2-1 flex-wrap-600 lib-card--grid-view tal">
    			<?php 
    					$resultshtml = array();
    
    					if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    						global $post;
    						//$resultshtml .= get_lib_card($post);
    						$resultshtml[] = get_lib_card_data($post);
    					endwhile; endif;
    					//echo $resultshtml;
    					
    					$thescript = '';
    					
    					$thescript .= '
    						<script>
    							var libCardJson = ' . json_encode($resultshtml, JSON_HEX_QUOT | JSON_HEX_TAG) . ';
    							var theTemplate = "' . get_lib_card_js_template() . '";
    							
    							';
    					
    						if(!is_library_ajax()) {
    							$thescript .= '
    								var defaultJson = libCardJson;
    								var notAjax = true;
    								var $defaultPagination = jQuery(".search-filter-results .pagination").clone();
    							';
    						} else {
    							$thescript .= 'var notAjax = false;';
    						}
    					$thescript .= '
    					
    						</script>
    					';
    				?>
    			</div>
    			
    		</section>
    	</div>
    </div>
    
    <div class="container-fluid">
    	<div class="row">
    		<div class="col-xs-12 tac">
    			<div class="pagination pr tac mt4">
    			<?php
    			    $total_pages = $query->max_num_pages;
    			 	
    			    if ($total_pages > 1){
    			        $current_page = max(1, $query->query['paged']);
    			 		
    
    					$big = 999999999; // need an unlikely integer
    					
    					echo paginate_links( array(
    						'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    						'format' => '?paged=%#%',
    						'current' => $current_page,
    						'prev_text' => __(''),
    						'next_text' => __(''),
    						'before_page_number' => '<div>',
    						'after_page_number' => '</div>',
    						'total' => $query->max_num_pages
    					) );
    			    }
    			?>
    			</div>
    		</div>
    	</div>
    </div>
    
    <?php
    	echo $thescript;
    ?>	

    Patrick
    Participant
    This reply has been marked as private.
    #211370

    Trevor
    Moderator

    I am sorry, but I do not understand. Do you mean you want to show the Posts count? For example, using our shortcode results method, the template uses this PHP:

    Found <?php echo $query->found_posts; ?> Results<br />

    #210717

    Trevor
    Moderator

    ‘To hide’ part.

    As you are using our Shortcode Display Results method, the guide to customising it is here:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results

    Your results.php file will have these lines in it (27-46):

    	?>
    	
    	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

    You need to remove these.

    With regard to the form, you also mentioned font sizing? I would use the browser developer tools inspector to work out what to change, and the gaps will be set as margins I would guess, but i would need to see a live link/URL to your search page so I can take a look.

    #209333

    Trevor
    Moderator

    I am sorry for the delay. I am working my way through a backlog and I answer posts is oldest last touched order, so yours was still another two or three down the list when you sent that last reply. The standard WordPress would, with your wp_query() array name, look like this:

    Found <?php echo $query_all->found_posts; ?> Results

    As to showing the filters, this is more complex. It would require custom coding when using the current version of Search & Filter Pro. You can access the filter terms though, but would need further PHP work to display them. To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    … and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

    #208449

    Andres Raffo
    Participant

    Here I have to add something, I have several pages and in each one I use a different personalized filter, each page corresponds to a department of Colombia, therefore, what we are looking for, is that the search result only brings results from that department, that’s why, if you go to the next two pages, you can see that the filter results are different.

    https://www.starpets.com.co/antioquia/
    https://www.starpets.com.co/cundinamarca/

    This I clarify, since after reviewing the help forum, I found this answer that you gave previously to a user https://support.searchandfilter.com/forums/topic/prevent-empty-search-fetching-results/#post -185868 but I do not know if it applies to my project, since here you indicate that you should replace the id of the page, but if there are several forms and each one has a different id, how can I achieve what you indicate?

    and so the code of my results.php file is displayed:

    <?php
    /**
    * Search & Filter Pro
    *
    * Sample Results Template
    *
    * @package Search_Filter
    * @author Ross Morsali
    * @link https://searchandfilter.com
    * @copyright 2018 Search & Filter
    *
    * 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>
    
    <?php
    while ($query->have_posts())
    {
    $query->the_post();
    
    ?>
    <div>
    <h2>"><?php the_title(); ?></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";
    }
    ?>

    I do not know if there is something wrong here too, because in the page where I’m trying to find the code, at the end of the results, this comes out:

    global $searchandfilter; $sf_current_query = $searchandfilter->get(2101)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) { echo ‘
    Nothing to see here folks!
    ‘; } else { // your template archive code/loop OR results.php code here }

    #207384

    Joshua Valentin
    Participant
    This reply has been marked as private.
    #207147

    dpolonsky
    Participant

    Ok so I found the issue – or at least what’s really happening. It’s not the orderby or any query args that I set.

    The query for S&F and WP are the same at this point. I even commented out any other pre_get_posts filters I may have had elsewhere in my theme. What happens is for some reason, there are these 5 posts that get put on the top regardless of the search term/order/whatever. So I tried using the WP search with a keyword that had 7 results. I got the same 7 results with the S&F search in the order I wanted, however 5 unrelated posts were on top of them.

    If I change the search term, use the sorting field to change the order, the results change like they’re supposed to, with the exception of those 5 persistent posts on top. It’s the strangest thing – why would that happen?

    I looked up the post IDs for these 5, and they are included in the post__in arg from S&F. I’m not finding any common link between them – they’re different post types. Different categories. I checked the post meta on one to see if there was custom meta from my end, nothing out of the ordinary.

    The results count is correct too, so if there are 7 results, $wp_query->found_posts will be 7. But what displays are those 7, plus those 5 results I can’t seem to get rid of. It’s really baffling.

    #206692

    Trevor
    Moderator

    That data is outputted by our results.php template when using the Shortcode results display method:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/

    In that documentation you can find the Customising guide. In the standard results.php template file, this is the code that you are asking about:

    Found <?php echo $query->found_posts; ?> Results<br />
    Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />

    If you wish to change (or delete it), you can.

Viewing 10 results - 21 through 30 (of 200 total)