Support Forums

The forums are closed and will be removed when we launch our new site.

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

Forums Forums Search Search Results for 'Sample Results Template'

Viewing 10 results - 1 through 10 (of 159 total)
  • Author
    Search Results
  • #270904

    Trevor
    Moderator

    This is the standard results.php template 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
     *
     */
    
    // If this file is called directly, abort.
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    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";
    }
    ?>

    The strings you want to translate are like this:

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

    In the file I showed above, these are on lines 34/35.

    Then on line 78 is this:

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

    Are those the lines you need?

    #268258

    Trevor
    Moderator

    You are using our shortcode method, so some background is important for me to explain. Our plugin files are located on your server in this location:

    …/wp-content/plugins/search-filter-pro

    There you will find a sub-folder named templates and in that a file named results.php.

    This documentation:

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

    tells the user to copy that file to their child theme folder, and place it in to a sub-folder that they should name search-filter

    Note that it is always good practice to use a child theme (this is a WordPress recommendation), as it stops updates of a theme from overwriting or deleting any changes and customizations).

    Similarly, if you fail to make that copy of the result.php template file and make your edits to that, then, when our plugin updates, it will overwrite the results.php file in our plugin templates folder.

    Then, you edit that results.php file to make the template for the page.

    The file, I think, needs this content:

    <?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() )
    {
    	?>
    	
    	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();
    		if(class_exists('WPBMap') && method_exists('WPBMap', 'addAllMappedShortcodes')) {
    			WPBMap::addAllMappedShortcodes();
    		}
    		?>
    		<div><?php echo get_the_content(); ?></div>
    		
    		<?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";
    }
    ?>

    This assumes that post post content of these results is as you show in those rows at the bottom of the page, as my method will show all the content of those posts.


    Trevor
    Moderator

    If you are using our Shortcode method, this is an alternate Infinite Scroll results.php file:

    <?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 ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    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
     }
    }
    ?>
    #266107

    Trevor
    Moderator

    Here is my version of that code, with new lines 30 and 58:

    <?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() ) {
    	?>
    	<div class="results-head clear">
    		<h1><?php _e('Nieuws & Blog artikelen','best4u');?></h1>
    	</div>
    	<div class='search-filter-results-list'>
    	<?php while ( $query->have_posts() ) : $query->the_post();
    //        $query->the_post();
    		$id        = get_post()->ID;
    		$image     = get_the_post_thumbnail_url( $id, 'medium_large' );
    		$title     = get_the_title( $id );
    		$permalink = get_the_permalink( $id );
    		?>
    		<div class="item span-4">
    			<?php if ( $image ): ?>
    				<div class="latest-news__thumb object-fit sz-16-9">
    					<a href="<?php echo $permalink; ?>" ><img class="lazy-img lazy" data-src="<?php echo $image; ?>"
    					     src="<?php echo get_template_directory_uri() ?>/placeholder.png"
    							alt="<?php echo $title ?>"></a>
    				</div>
    			<?php endif; ?>
    			<div class="latest-news__cnt">
    				<h3><a href="<?php echo $permalink;  ?>"><?php echo $title; ?></a></h3>
    				<div class="content">
    					<?php echo my_content( 20, false, false ); ?>
    				</div>
    				<div class="link">
    					<a href="<?php echo $permalink; ?>"
    					   class="read-more"><?php _e( 'Lees meer', 'best4u' ); ?></a>
    				</div>
    			</div>
    		</div>
    	<?php endwhile; ?>
    	</div>
    	<?php
    	if ( function_exists( 'wp_pagenavi' ) ) { ?>
    		<div class="pagination">
    			<?php wp_pagenavi( array( 'query' => $query ) ); ?>
    		</div>
    	<?php } ?>
    	<?php
    } else {?>
    	<h3><?php _e('Geen resultaten gevonden','best4u')?></h3>
    <?php } ?>
    #264527

    In reply to: Infinite Scroll


    Iñigo Flores
    Participant
    This reply has been marked as private.
    #264463

    Dennis Köhler
    Participant
    This reply has been marked as private.
    #262848

    Trevor
    Moderator

    You could use this alternative results.php template:

    <?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 ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    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
     }
    }
    ?>
    #260600

    Paul Ksi
    Participant

    each filter template is pretty much the same

    <?php
    	/**
    		* Search & Filter Pro 
    		*
    		* Sample Results Filter News
    		* 
    		* @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;
    		
    		
    		
    	}
    	
    	
    ?>
    <div id="site_post_feed">
    	<?php
    		
    		if ( $query->have_posts() )
    		{
    		?>
    		
    		
    		
    		<?php
    			
    			while ($query->have_posts())
    			{
    				$query->the_post();
    				
    			?>
    			
    				<div id="site_post_feed_item">
    					<div id="site_post_feed_item_featured_image">
    						<a href="<?php echo get_the_permalink();?>"><?php echo get_the_post_thumbnail(); ?></a>
    					</div>
    					<div id="site_post_feed_item_item_title">
    						<a href="<?php echo get_the_permalink();?>">
    						<?php echo get_the_title() ?></a></div>
    						<div id="site_post_feed_item_item_excerpt"><a href="<?php the_permalink() ?>">
    							<?php echo wp_trim_words( get_the_excerpt(), 20, $moreLink = null)?>
    						</a></div>
    						<div id="site_post_feed_item_item_category">
    							
    							
    							<?php echo wpdocs_custom_taxonomies_terms_links(); ?>
    							
    							
    						</div>	
    						<div id="site_post_feed_item_date">
    							<a href="'<?php the_permalink() ?>"><?php echo get_the_date() ?></a>
    						</div>
    				</div>	
    		
    			
    			<?php
    			}
    			
    			
    		?>
    		
    		
    		
    		<?php
    		}
    		else
    		{
    			//	echo "No Results Found";
    		}
    	?>
    	
    </div>
    <div class="pagination">
    	<div class="pagination" id="site_pagination"></div>	
    	
    	<?php
    		/* example code for using the wp_pagenavi plugin */
    		if (function_exists('wp_pagenavi'))
    		{
    			echo "<br />";
    			wp_pagenavi( array( 'query' => $query ) );
    		}
    	?>
    	
    </div>
    #260508

    In reply to: duplicate results


    Sky Esser
    Participant

    Thanks so much!! I’m trying the code tick thing here, but here’s a link to the file, too, just in case: https://www.dropbox.com/s/lq01m81d0zc5qnt/results.php?dl=0 — Thanks again for the prompt reply and support!

    <?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>			
    			<p><?php the_content(); ?><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";
    }
    ?>
    #260430

    Paul Ksi
    Participant

    `<?php
    /**
    * Search & Filter Pro
    *
    * Sample Results Filter News
    *
    * @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;

    }

    ?>
    <div id=”site_post_feed”>
    <?php

    if ( $query->have_posts() )
    {
    ?>

    <?php

    while ($query->have_posts())
    {
    $query->the_post();

    ?>

    <div id=”site_post_feed_item”>
    <div id=”site_post_feed_item_featured_image”>
    <a href=”<?php echo get_the_permalink();?>”><?php echo get_the_post_thumbnail(); ?></a>
    </div>
    <div id=”site_post_feed_item_item_title”>
    <a href=”<?php echo get_the_permalink();?>”>
    <?php echo get_the_title() ?></a></div>
    <div id=”site_post_feed_item_item_excerpt”><a href=”<?php the_permalink() ?>”>
    <?php echo wp_trim_words( get_the_excerpt(), 20, $moreLink = null)?>
    </a></div>
    <div id=”site_post_feed_item_item_category”>

    <?php echo wpdocs_custom_taxonomies_terms_links(); ?>

    </div>
    <div id=”site_post_feed_item_date”>
    <a href=”‘<?php the_permalink() ?>”><?php echo get_the_date() ?></a>
    </div>
    </div>

    <?php
    }

    ?>

    <?php
    }
    else
    {
    // echo “No Results Found”;
    }
    ?>

    </div>
    <div class=”pagination”>
    <div class=”pagination” id=”site_pagination”></div>

    <?php
    /* example code for using the wp_pagenavi plugin */
    if (function_exists(‘wp_pagenavi’))
    {
    echo “<br />”;
    wp_pagenavi( array( ‘query’ => $query ) );
    }
    ?>

    </div>

Viewing 10 results - 1 through 10 (of 159 total)