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 - 191 through 200 (of 254 total)
  • Author
    Search Results

  • Trevor
    Moderator

    Just in case this happens again, this is the code I wrote:

    <?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
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(5048)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo ''; 
    } else {
    	
    	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>
    <div class="slz-shortcode sc_block_posts "><div class="slz-template-03 ">
    	<div class="slz-list-block slz-column-2">
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div class="item">
    			<div class="slz-block-item-01 style-1">
    			<?php if ( has_post_thumbnail() ) {?>
    					<div class="block-image">
         <a href="<?php the_permalink(); ?>" class="link">
          <?php the_post_thumbnail("full", array( 'class' => 'img-responsive' ));?>
    					</a>
        </div>
    			<?php } ?>
        <div class="block-content">
         <div class="block-content-wrapper">
    			   <a class="block-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    						<ul class="block-info">
    							<li><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><span class="author-label">By </span><span class="author-text"><?php the_author(); ?></span></a></li>
    						 <li><a href="<?php the_permalink(); ?>" class="link date"><?php the_date(); ?></a></li>
    						 <li><a href="<?php the_permalink(); ?>#comments" class="link comment"><?php comments_number();?></a></li>
           <li><a href="<?php the_permalink(); ?>" class="link view">?? Views</a>
                            </li>
    						 <li><?php the_category(); ?></li>
    						</ul>
    						<div class="block-text"><?php echo get_the_excerpt(); ?></div>
    
    			  </div>
    		  </div>
    			
    			</div>
    		</div>
    		
    		<?php
    	}
    	?>
    	</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";
    }
    }
    ?>
    #83677

    Trevor
    Moderator

    I have written a new results.php for you:

    <?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 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="col-9 hb-equal-col-height hb-main-content">
    		<div id="hb-blog-posts" class="hb-blog-grid masonry-holder clearfix" data-layout-mode="fitRows" data-categories="" data-column-size="col-4">
    	
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
       <article id="post-<?php echo get_the_ID();?>" class="col-4 post-<?php echo get_the_ID();?> post type-post status-publish format-standard has-post-thumbnail hentry" itemscope="" itemtype="http://schema.org/BlogPosting">
    				<div class="featured-image">
    					<a href="<?php the_permalink(); ?>">
    			<?php 
    				if ( has_post_thumbnail() ) {
    					the_post_thumbnail("small");
    					?>
            <div class="featured-overlay"></div>
            <div class="item-overlay-text" style="opacity: 0;">
              <div class="item-overlay-text-wrap" style="padding-top: 0px;"> <span class="plus-sign"></span> </div>
            </div>
       <?php
    				}
    			?>
    					</a>
    				</div>
    				<div class="post-content">
    					<div class="post-header">
       			<h2 class="title" itemprop="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    					</div>
     			 <p><?php echo get_the_excerpt(); ?>
    	 			<br /><a href="<?php the_permalink(); ?>" class="read-more">Read More</a>
    		 		</p>
    				</div>
      	</article>
    		
    		<?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";
    }
    ?>
    #80566

    Trevor
    Moderator

    Part of it uses this, I think:

    <?php echo $query->found_posts; ?>
    
    #79193

    Trevor
    Moderator

    OK, if you have followed the documentation to make a copy of the results.php into a new folder called search-filter in your child theme or theme folder, then replace the contents of that template file with this (change the number 255 for the ID number of your search form and change the line echo '<div>Nothing to see here folks!</div>'; for whatever you want before the filter is used instead of the results – or remove for nothing at all):

    <?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
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(255)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
    	
    	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";
    }
    }
    ?>
    #78756

    Trevor
    Moderator

    It MIGHT be possible using PHP, something like this:

    <?php global $wp_query; ?>
    <div>Found <?php  echo $wp_query->found_posts; ?> Posts</div>

    But the query name might be the issue, because it depends on your theme. I stumbled on this by accident because I was trying to find how many posts there were after filtering, but this code gave me the total number before filtering.

    For my own needs I have spent over a week on this without any joy, so I am fairly sure I can’t offer much more help.

    #78527

    Nigel Roper
    Participant

    Hello,
    Could you please advise on how I can retrieve maximum number of posts in my PHP Results script? I want be able to display a message along the lines of “Showing x of y items”. I can use “found_posts; ?>” to show x. How do I find y?

    Thank You (still learning WP so apologies if this is a dumb question)


    Trevor
    Moderator

    OK, nearly there. This is the code we have so far:

    <?php
      global $searchandfilter;
      $sf_query = $searchandfilter->get(3217)->current_query();
      if ($sf_query->is_filtered()) {
    ?>
    <div>Found <?php echo $sf_query->found_posts; ?> Results</div>
    <?php
      $sf_current_query = $searchandfilter->get(3217)->current_query()->get_array();
    if (($sf_current_query['_sft_category']['active_terms'][0]['name'])<>"") echo "<div>KATEGORIJE: " . ($sf_current_query['_sft_category']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sft_post_tag']['active_terms'][0]['name'])<>"") echo "<div>OZNAKE: " . ($sf_current_query['_sft_post_tag']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name'])<>"") echo "<div>KAKOVOST SPREMEMBE: " . ($sf_current_query['_sfm_kakovost_spremembe']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_starost']['active_terms'][0]['name'])<>"") echo "<div>STAROST: " . ($sf_current_query['_sfm_starost']['active_terms'][0]['name']) . "</div>";
    if (($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name'])<>"") echo "<div>VRSTA PRIMERA: " . ($sf_current_query['_sfm_vrsta_primera']['active_terms'][0]['name']) . "</div>";
    }
    ?>

    And we know that the only part NOT working is:

    <div>Found <?php echo $sf_query->found_posts; ?> Results</div>
    
    #74878

    Trevor
    Moderator

    Are you using the Shortcode Display results method?

    If yes, did you make a copy of the results.php template file as shown in the documentation:

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/#Customising_the_Results

    This allows you to customize the file by editing it.

    You would need to remove lines 29 and 30:

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

    Alexander Hertzberg
    Participant

    [split by @trevorsf from https://support.searchandfilter.com/forums/topic/how-to-not-show-results-in-first-search-translate-older-newer-posts-2/ ]

    Hello!

    I have the same problem and can’t find the place to put your suggested solution (quoted below). Could you help me out? 🙂


    Something like 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
    *
    */

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1726)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==””)) {
    echo ‘<div>Nothing to see here folks!</div>’;
    } else {

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

    #70946

    Alex Shanks
    Participant
    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>
    			<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    			<p><br /><?php the_excerpt(); ?></p>
    			<?php 
    				if ( has_post_thumbnail() ) {
    					echo '<p>';
    					the_post_thumbnail("small");
    					echo '</p>';
    				}
    			?>
    			<h6>Average Rating: <span id="post-ratings-<?php get_the_ID();?>" class="post-ratings"><?php
    $star_rating = get_post_meta( get_the_ID(), 'ratings_average', true );
    for ( $star_count = 1, $star_count <= 5, $star_count++) {
    $star_status = "on";
    if ( $star_rating < $star_count ) {
    $star_status = "off";
    }
    ?><img id="rating_<?php get_the_ID();?>_<?php echo $star_count;?>" src="http://www.golf-library.com/wp-content/plugins/wp-postratings/images/stars/rating_<?php echo $star_status;?>.gif" alt="Star" title="Star"><?php } ?></span></h6> <p>Votes: <?php echo get_post_meta( get_the_ID(), 'ratings_users', true ); ?><p>
    			<p></p>
    			<p><small></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";
    }
    ?>
Viewing 10 results - 191 through 200 (of 254 total)