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 - 11 through 20 (of 254 total)
  • Author
    Search Results
  • #263000

    Masayoshi Serata
    Participant

    Hello.
    The standard theme works fine, but the production theme gives 0 results.
    I don’t know what caused it.

    Write down the contents of search.php

    <?php
    /**
    * Luxeritas WordPress Theme – free/libre wordpress platform
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    * @copyright Copyright (C) 2015 Thought is free.
    * @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
    * @author LunaNuko
    * @link https://thk.kanzae.net/
    * @translators rakeem( http://rakeem.jp/ )
    */

    global $luxe, $s;
    get_header();

    if( function_exists( ‘thk_search_result’ ) === false ) {
    function thk_search_result() {
    global $s, $wp_query; ?>
    <p id=”list-title”><?php echo
    sprintf( __( ‘Search results of [%s]’, ‘luxeritas’ ), esc_html( $s ) ) .
    sprintf( __( ‘ : %s’, ‘luxeritas’ ), $wp_query->found_posts );
    ?></p><?php
    }
    }
    ?>
    <input type=”hidden” id=”search-result” value=”<?php echo esc_html( $s ); ?>” />
    <?php
    if( !empty( $s ) && have_posts() === true ) {
    ?>
    <div id=”section”<?php echo $luxe[‘content_discrete’] === ‘indiscrete’ ? ‘ class=”grid”‘ : ”; ?>>
    <?php
    get_template_part( ‘loop’ );
    ?>
    </div><!–/#section–>
    <?php
    }
    else {
    ?>
    <article>
    <div id=”core” class=”grid”>
    <?php
    if( $luxe[‘breadcrumb_view’] === ‘inner’ ) get_template_part( ‘breadcrumb’ );
    ?>
    <div itemprop=”mainEntityOfPage” id=”post”>
    <h2 id=”list-title”><?php echo __( ‘No search hits’, ‘luxeritas’ ); ?></h2>
    <p><?php echo __(‘Sorry, the requested post was not found.’, ‘luxeritas’); ?></p>
    </div><!–/#post–>
    </div><!–/#core–>
    </article>
    <?php
    }
    ?>
    </main>
    <?php thk_call_sidebar(); ?>
    </div><!–/#primary–>
    <?php echo apply_filters( ‘thk_footer’, ” ); ?>

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

    Danny Albeck
    Participant
    This reply has been marked as private.
    #261833

    Trevor
    Moderator

    You can write some custom code to find the filter terms in use, but it does requires some digging to find the variable names first (especially if you allow more than once choice per field), and you can find the total results count. So, this code gets the count (but you need the query variable/array name, so it might not be $query):

    $number_of_results = $query->found_posts;

    To figure that the variables are, you need to output the array holding the filter, then make a note of the variable names. see this post:

    https://support.searchandfilter.com/forums/topic/acf-post-meta-fields-in-current_query-result/#post-249704

    #261096

    Moe Finigan
    Participant
    This reply has been marked as private.
    #261295

    Moe Finigan
    Participant
    This reply has been marked as private.
    #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";
    }
    ?>
    #260478

    In reply to: Display Results


    Trevor
    Moderator

    In the template file for that page, you need to find where it calls the pagination. The chances are it is a call to an external function. You will need to edit the template file (using a child theme copy of the file for safety) and remove that pagination function and replace it.

    For example, the WP-PageNavi plugin is a very popular pagination plugin, and if you have that installed, the code might be something like I show here:

    https://support.searchandfilter.com/forums/topic/display-results-on-the-current-taxonomy-page/#post-257222

    WP-PageNavi can also add page xx of xxx.

    Similarly, to add the number of results code, assuming the results array is named $query:

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

    Editing your template files would be outside the scope of our support, so you would need the help of the theme author or a third party coder.

    #260281

    Alwyn Finch
    Participant
    This reply has been marked as private.
    #260159

    Alwyn Finch
    Participant

    I’ve updated so more in line with original

    <?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>
    <?php get_template_part(‘template-parts/content’, get_post_type()); ?>

    </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”;
    }
    ?>

Viewing 10 results - 11 through 20 (of 254 total)