Forums Forums Search Search Results for 'found_posts'

Viewing 10 results - 51 through 60 (of 174 total)
  • Author
    Search Results
  • #211370

    Trevor
    Participant

    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
    Participant

    ‘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
    Participant

    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

    Anonymous
    Inactive

    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 }

    #207147

    Anonymous
    Inactive

    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
    Participant

    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.

    #204436

    Anonymous
    Inactive

    Here’s the search.php template. Still not sure what you mean. This functionality used to work. and then stopped. Shall we display results as a post-archive instead?

    <?php
    /**
     * The template for displaying search results pages. Uses built-in WordPress search or Relevanssi search, 
     * with Google Custom Search Form at the bottom as an alternative
     * 
     *
     * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
     *
     * @package copblue
     */
    
    get_header(); ?>
    
    	<div class="container">
    		<div class="row">
    			<section id="primary" class="fullwidth-content-area">
    				<main id="main" class="site-main" role="main">
    					
    
    					<header class="entry-header text-center">
    						<?php echo '<h1 class="entry-title">Search Results</h1>'; ?>
    					</header><!-- .entry-header -->
    
    					
    
    				<?php
    				if ( have_posts() ) : ?>
    
    					<div class="search-form mb-3"><?php get_search_form(); ?></div>
    					<h5 class="page-title"><?php printf( esc_html__( 'Found %u results for: %s', 'copblue' ), $wp_query->found_posts, '<span><i>' . get_search_query() . '</i></span>' ); ?></h5>
    					<hr>
    					
    					
    
    					<?php
    
    					
    
    					/* Start the Loop */
    					while ( have_posts() ) : the_post();
    
    						/* The code below is necessary for Relevanssi Multisite search. Remove if not using Relevanssi as a search engine or if not using it in multisite mode */
    						switch_to_blog($post->blog_id);
    
    						/**
    						 * Run the loop for the search to output the results.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-search.php and that will be used instead.
    						 */
    						get_template_part( 'template-parts/content', 'search' );
    
    						/* This code is necessary for Relevanssi Multisite search. Remove if not using Relevanssi as a search engine or if not using it in multisite mode */
    						restore_current_blog();
    
    					endwhile; ?>
    
    					<div class="mb-3">
    
    					 <?php the_posts_pagination( array(
    
    						'mid_size'  => 5,
    						'prev_text' => __( 'Previous', 'textdomain' ),
    						'next_text' => __( 'Next', 'textdomain' ),
    						)
    					); ?>
    
    					</div>
    
    				<?php
    
    				else :
    
    					get_template_part( 'template-parts/content', 'none' );
    
    				endif; ?>
    
    					<div class="google-cse-form mb-3">
    						<hr>
    						<h5> If you still can't find what you are looking for, try our Google On-Site Search below</h5>
    						<?php //echo do_shortcode( '[wp_google_searchbox]' ); ?>
    						<?php get_template_part( 'template-parts/content', 'gcse-form' );?>
    						
    					</div>
    
    			
    
    				</main><!-- #main -->
    			</section><!-- #primary -->
    
    <?php
    
    get_footer();
    
    #202893

    In reply to: Hide results number


    Trevor
    Participant

    You appear to be 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

    Find this line (I think line #29):

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

    and delete it.

    #200574

    Trevor
    Participant

    It would require adding PHP like this:

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

    in the PHP template, inside the Ajax Container if you are using Ajax to load the filtered results).

    You might need to seek the help of either Beaver Builder support or a third party coder to do this.

    #200124

    Trevor
    Participant

    Hi

    This is an alternative exemplar results.php file content that might do as you want:

    <?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 />
     <div class='search-filter-results-list'>
     <?php
      while ($query->have_posts())
      {
       $query->the_post();
       
       ?>
       <div class='search-filter-result-item'>
        <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>
        
        <hr />
       </div>
       
       <?php
      }
     ?>
     </div>
    <?php
    } else {
     
     //figure out which type of "no results" message to show
     $message = "noresults"; 
     if(isset($query->query['paged'])) {  
      if($query->query['paged']>1){
       $message = "endofresults";
      }
     }
     
        if($message=="noresults") {
        ?>
     <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
      <span>No Results Found</span>
     </div>
     <?php
        } else {
     ?>
     <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
      <span>End of Results</span>
     </div>
     <?php
     }
    }
    ?>
Viewing 10 results - 51 through 60 (of 174 total)