Forums Forums Search Search Results for 'found_posts'

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

    Trevor
    Participant

    In place of this line:

    // the current products output code here

    … you would place the code part of the results.php file, which, by default, would be this part:

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

    Anonymous
    Inactive

    Hey guys,

    we have about 50 results in total and 20 per page. The results page shows that there are 3 pages (before applying any filters) which is correct. But you can’t click through them before applying a filter.

    Here’s the link to the website:
    https://hypnoschool.de/therapeutenliste/uebersicht

    Heres ist the code fom my results.php

    
    <?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 this file is called directly, abort.
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    if ( $query->have_posts() )
    {
    	?>
    	
    	<?php echo $query->found_posts; ?> Ergebnisse gefunden<br />
    	Seite  <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></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 class="therapeut">
    			<p><a href="<?php the_permalink(); ?>"><?php the_field("name"); ?></a></p>
    			
    			<?php 
    				if ( has_post_thumbnail() ) {
    					echo '<p>';
    					the_post_thumbnail("thumbnail");
    					echo '</p>';
    				}
    			?>
    			<p><?php the_field("land"); ?></p>
    			<p><?php the_field("plz_&_stadt"); ?></p>
    			
    		</div>
    		
    		<hr />
    		<?php
    	}
    	?>
    	Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></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 "Keine Ergebnisse gefunden";
    }
    ?>
    #250548

    Anonymous
    Inactive

    Hi Trevor thank you for the help- I tried adding the code to the top and replacing and it did not sort the tags alpahbetically. Where I am trying to accomplish this is the left side “Tags” filter on the resources page (https://hceg.org/resources/) before and after filtering.

    Here is the current code I updated on the search-filter/results.php file

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

    function compare_tags_naturally($a, $b) {
    return strnatcmp($a->name, $b->name);
    }
    if ( $query->have_posts() )
    {
    ?>

    <div style=”text-align: right”>
    <?php global $searchandfilter;
    $sf_current_query = $searchandfilter->get(13622)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) { } else { ?>
    Found <?php echo $query->found_posts; ?> Results,
    <?php } ?>
    Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?></div>

    <div class=”pagination”>

    <div class=”nav-previous”><?php next_posts_link( ‘Previous’, $query->max_num_pages ); ?></div>
    <div class=”nav-next”><?php previous_posts_link( ‘Next’ ); ?></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>” target=”_blank” class=”read_more_link”><?php the_title(); ?></h2>

    <?php the_excerpt(); ?>
    <?php
    if ( has_post_thumbnail() ) {
    echo ‘<p>’;
    the_post_thumbnail(“small”);
    echo ‘</p>’;
    }
    ?>
    <p><?php the_category(); ?></p>
    <?php
    $unsorted_tags = get_the_tags();
    $tags = usort($unsorted_tags, ‘compare_tags_naturally’);
    ?>
    <p><?php echo implode(‘, ‘, $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( ‘Previous’, $query->max_num_pages ); ?></div>
    <div class=”nav-next”><?php previous_posts_link( ‘Next’ ); ?></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”;
    }
    ?>

    #249703

    Trevor
    Participant

    In the form setting, which Display Results method are you using?

    From your question, I assume that you are not using our Shortcode Display results method. If you are using some form of page builder, what you want will not currently be possible (but we hope to make it so in V3, due in a few months).

    If you are using the As and Archive, Post Type Archive or some of the methods that use the Custom method, and if you have access to a PHP template that is used in the display of the page/results, then it is, with good PHP skills, to code what you want. You would need to know what the results array variable is named if you are using a theme PHP template. It is often named $query or $wp_query, but can be anything the developer of the theme wants.

    For example, to display the number of results, code LIKE this would do that:

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

    Code LIKE this (change the ID number to be that of your form) would display the text search term, for example:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(12345)->current_query();
    if (!$sf_current_query->get_search_term()=="") {
      echo '<div>Displaying: ' . $sf_current_query->get_search_term() . '</div>'; 
    }

    You would want these code snippets placed inside the block that is being refreshed with Ajax (the ‘Ajax Container’).

    #246641

    Anonymous
    Inactive

    I do, thanks. However, it’s now outputting the text ‘ArrayAntigonish’ (or ‘Array’ + whatever county is selected) and it’s not outputting category name. I have tried to puzzle through this to see if I can work out how to fix it myself but my PHP just isn’t good enough.

    Here’s a link to a sample results page.

    What I’d like it to say is something like “You searched for Breweries, Distilleries, and Vineyards in Antigonish County” and then the results.

    Below is the full code of results.php. If you can offer any more insight I’d be grateful.

    <?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 this file is called directly, abort.
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    if ( $query->have_posts() )
    {
    	?>
    	
    	There are <?php echo $query->found_posts; ?> posts that match your search! <br />
    
    	<?php
    	
    	 global $searchandfilter;
    	 
    $sf_current_query = $searchandfilter->get(1949)->current_query()->get_array();
    
    echo implode(", ",$sf_current_query['_sft_category']['active_terms']);
    $county = $sf_current_query["_sfm_county"]["active_terms"][0]["value"];
    if ($county) {
    echo $county;
    } else {
    echo "All Counties";
    }
    	
    
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div>
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			
    			<p><?php the_excerpt(); ?></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( 'Next page', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Previous page' ); ?></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";
    }
    ?>
    #246534

    Trevor
    Participant

    Ah, I see, you would have to edit the archive template and add code LIKE this, but you need to know the name of the wp_query array variable, which might not be $query (it varies from theme to theme, many use $wp_query instead):

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

    Trevor
    Participant

    That issue is simply the way that whatever code outputs the posts handles a ‘No Results Found’ scenario. As you are using our Shortcode method, and thus the infinite scroll version of results.php, this customized version handles ‘No Results’ better I think:

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

    Try using that instead?

    #245870

    Trevor
    Participant

    You have chosen to use for now our Shortcode display results method, which means that the style of the display is somewhat basic, but can be customized by yourself:

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

    It depends what content you want (what taxonomies, images, description, custom fields) and layout you want, as that will determine how easy it will be to do.

    #1 This code:

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

    Would become this:

    <div style="text-align: right">Found <?php echo $query->found_posts; ?> Results, Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>

    #2 The above code would then become:

    <div style="text-align: right">
    <?php global $searchandfilter;
    $sf_current_query = $searchandfilter->get(13622)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { } else { ?>
    Found <?php echo $query->found_posts; ?> Results, 
    <?php } ?>
    Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></div>

    #3 This space?

    https://www.screencast.com/t/GuYOFQ3qtQ3l

    There appears to be blank lines in your content:

    https://www.screencast.com/t/SivDBdT69fK

    #4 This would require our filter to use (or be able to use) transients, which it cannot at present. I believe this will be added when we release V3, towards the end of June/early July.

    Even then, you would probably require the services of a coder to hook it all up.

    #245168

    Trevor
    Participant

    I checked back on my notes and before, with Thrive, I ‘cheated’ by creating a custom results.php template that mimicked the Thrive page. So, make the page and content as you like ignoring our plugin entirely, then inspect the HTML of the content area and edit the results.php we provide as an exemplar following this guide, so that it matches the structure and classes etc.):

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

    So, here is one I made before:

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Thrive Results Template
     * 
     */
    
    if ( $query->have_posts() )
    {
    	?>
    	
    	Found <?php echo $query->found_posts; ?> Cars<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="thrv_wrapper thrv_post_grid" data-unit="px">
    	  <div class="tve_post_grid_wrapper tve_clearfix tve_post_grid_grid">
    
            <div style="display: flex;" class="tve_pg_row tve_clearfix">
    
    	<?php
        $thrive_counter = 0;
        $thrive_row_counter = 0;
    	while ($query->have_posts())
    	{
          if ( $thrive_counter == 0 ) && ( $thrive_row_counter > 0 ) {
          ?>
    	    </div>
            <div style="display: flex;" class="tve_pg_row tve_clearfix">
          <?php
          }
          $query->the_post();
    		
          ?>
    			<div class="tve_post tve_post_width_5 " style="align-items: stretch;">
                  <div class="tve_pg_container">
    			
    			
    			<?php 
                  if ( has_post_thumbnail() ) {
                    $thrive_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'single-post-thumbnail' );
    			?>
                      <a href="<?php the_permalink(); ?>">
                        <div class="tve_post_grid_image_wrapper" style="background-image: url('<?php echo $thrive_image[0]; ?>')">
                          <div class="tve_pg_img_overlay">
                            <span class="thrv-icon thrv-icon-forward"></span>
                          </div>
                        </div>
                      </a>
    			<?php
                  }
    			?>
    
    		        <span class="tve-post-grid-title " style="font-size: 18px;line-height: 20px;font-family:'Arial', 'Helvetica', 'sans-serif';">
                      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                    </span>
    
                    <div class="tve_pg_more" data-tve-custom-colour="62938813">
                      <a href="<?php the_permalink(); ?>">View Now</a>
                      <span class="thrv-icon thrv-icon-uniE602"></span>
                    </div>
    			
                  </div>
                </div>
    		
    		<?php
          $thrive_counter++;
          if ( $thrive_counter > 4 ) {
            $thrive_counter = 0;
            $thrive_row_counter++;
          }
    	}
    	?>
    	    </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";
    }
    ?>
    #244401

    Anonymous
    Inactive

    Hi there,
    I’m trying to show number of results on term page but it’s always displaying plural version instead of one (I have only one service to show).

    `<?php
    $results = $wp_query->found_posts;
    if (0 === $results) {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . __(‘No service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    }
    elseif (1 === $results) {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    } else {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ services’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    }
    ?>’

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