Forums Forums Search Search Results for 'results.php'

Viewing 10 results - 341 through 350 (of 1,224 total)
  • Author
    Search Results
  • #205597

    Trevor
    Participant

    If you look in the Search and Filter pro plugin folder, you will see a templates sub-folder. Look at the exemplar results.php template that shows how to structure the loop so that there is a No Results message.


    Anonymous
    Inactive

    Hello. New user here.

    I’m having trouble getting pagination AND filtering to work. It’s one or the other, not both.

    I’m using filtering on a Custom Post Type Archive in a custom theme. I tried to adapt my code to work like the results.php file, but it kept failing on the pagenavi args.

    wp_pagenavi( array( 'query' => $the_query ) ); <– this just kept killing the page.

    So.. I tried to simplify the query so it was a little more basic, but no matter what I pass to the ‘query’ arg in wp_pagenavi, nothing works.

    The problem here, is I need to alphabetize my unfiltered results by a custom_meta. I’ve tried to search through support and try a few things, but I’m not getting it to work.

    This is the code I’m pulling into my archive-thoughtleaders.php via get_template_party :

    
    <?php
    	$posts = get_posts(array(
    		'post_type'			=> 'thoughtleaders',
    		'posts_per_page'	=> 10,
    		'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    		'meta_key'			=> 'last_name',
    		'orderby'			=> 'meta_value',
    		'order'				=> 'ASC'
    	));
    ?>
    <?php //$the_query = new WP_Query( $posts ); // the results.php file didn't have this.. BUT without this, the $the_query from results.php sample throws an error on pagenavi. But docs say don't use custom loops. this essentially breaks the filtering but makes pagination work. '?>
    
    <?php if ( have_posts() ) : ?>
    	
    	<?php if (function_exists('wp_pagenavi')) { ?>
    		<div class="pagination">
    			<?php wp_pagenavi( array( 'query' => $the_query ) ); ?>
    			<?php //wp_pagenavi(); ?>
    		</div>
    	<?php } ?>
    	
    	<div class="leaderDirectory">
    	
    	<?php while ( have_posts() ) : the_post(); ?>
    		
    		<div class="leaderEntry">
    			<a  href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    				<?php if ( has_post_thumbnail() ) { ?>
    					<?php the_post_thumbnail('headshot-large');?>
    				<?php } else { ?>
    					<img src="https://via.placeholder.com/680x680" alt="" />
    				<?php } ?>
    				<div class="leaderEntryMeta">
    					<h4><?php the_title(); ?></h4>
    					<?php //the_excerpt(); ?>
    					<p><?php echo wp_trim_words( get_the_excerpt(), 20, '&hellip;' ); ?></p>
    					<p class="readMore">read more</p>
    				</div>
    			</a>
    		</div>
    		
    	<?php endwhile; ?>
    	
    	</div>
    	
    	<?php if (function_exists('wp_pagenavi')) { ?>
    		<div class="pagination">
    			<?php wp_pagenavi( array( 'query' => $the_query ) ); ?>
    			<?php //wp_pagenavi(); ?>
    		</div>
    	<?php } ?>
    
    <?php else : ?>
    	 <p>No Results Found</p>
    <?php endif; ?>

    Anonymous
    Inactive

    Hi,

    On the following website we have an overview of news with S&F pro. On the bottom of the page under “Actueel”.
    http://hvarcade.bureaufeith1.nl/

    Now we’ve set it on loading in with Ajax for the pagination. However Ajax doesn’t seem to work for this website.

    We’ve tried quite a bit but can’t seem to find something conflicting. The page just keeps reloading:

    • The default results.php file with the default pagination.
    • Twenty Seventeen theme.
    • Disable all other plugins.
    • Delete or disable all scripts that have any connection with Ajax or javascript.

    Dont know if there’s anything we’re missing. Hope you can help!

    Best regards,
    Jos

    #205356

    Anonymous
    Inactive

    I just simply changed the theme on the wordpress dashboard (and then manually copied key files over–namely the “search-filter” folder containing the results.php (infinity scrolling version) and some other unrelated files), no formal migration and no change of host server.

    #204823

    Trevor
    Participant

    Hi

    When using the shortcode method, the results.php file can be named:

    results.php

    OR (for example):

    1234.php

    Where the form ID would be that number. This gives you the opportunity to translate the templates, once you know the ID number of the translated form, make a template to match that number, in the search-filter sub folder and translate it.

    #204644

    Trevor
    Participant

    To hide first results.

    You now have a block of code in the results.php file (Ignoring the initial comments).

    You need to add/wrap some code around the code you have, like this:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(36613)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // your current results.php code here
    }

    … where the ID number will need to be changed to match your form ID

    #204638

    Anonymous
    Inactive

    Hello Trevor, yes I used your infinite scroll template and now I named it results.php (before it had a different name and I don’t think it made any difference). Anyway the submit button still does not work, can you help me please?
    https://www.dev.socage.it/products/

    I had a look at your documentation which is quite wide and most of it is difficult to understand for my background knowledge. I’ll be very grateful if you can you help me to find the page I need to try hiding first results.

    Finally I don’t want to use Ajax, and anywhere in the setting I disabled it.One problem less.
    Thank you so much for your help!

    #204620

    Trevor
    Participant

    As you are using our shortcode method, the guide for customization is here:

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

    Note that in your plugin templates folder are TWO templates. If you are using infinite scroll, use that one there, but rename it to results.php, as the structure required is different.

    Ajax will only work if the HTML element jQuery id/class name is in this file, and NOT hidden inside an included file.


    Anonymous
    Inactive

    Thanks for your reply.

    The links are not from the search results (overlay), they are from the other pagination that’s on a page. And that pagination should not use anything from S&F.

    I tried your suggestion, but it did not help. So using “infinite scroll” or “normal” as the pagination type makes no difference, no matter how I set the classes for the containers/selectors.

    This is the results.php that I’m using (with infinite scroll on):

    <?php
    
    if ( $query->have_posts() )
    {
    	?>
    	<div class='search-filter-results-list'>
    	<?php
    		while ($query->have_posts())
    		{
    			$query->the_post();
    			?>
    			<div class='search-filter-result-item'>
    				<h2><?php the_title(); ?></h2>
    				<p><?php echo search_excerpt(30); ?></p>
    			</div>
    			<?php
    		}
    	?>
    	</div>
    <?php
    }
    else
    {
    	?>
    	<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'></div>
    	<?php
    }
    ?>

    Although I don’t think that’s where the problem is, as I tried the core ones that come with this plugin and the problem still exists.

    On the S&F settings page I have set “Infinite Scroll Container” to .search-overlay .search-filter-results-list. Ajax is on, bookmarking is on..

    And this is the way the overlay is created on every page:

    <div class="search-overlay">
      <div class="search-content">
        <div class="search-toggle search-toggle-close">
          <img src="URL-TO-IMG" width="54" height="34" />
        </div>
        <div class="search-input">
          <?php echo do_shortcode('[searchandfilter id="2947"]'); ?>
        </div>
        <div class="search-results">
          <?php echo do_shortcode('[searchandfilter id="2947" show="results"]'); ?>
        </div>
        <?php if ( is_active_sidebar( 'nav_bottom_nineteen' ) ) : ?>
          <div class="widget-area nav-main-bottom" role="complementary">
            <?php dynamic_sidebar( 'nav_bottom_nineteen' ); ?>
          </div>
        <?php endif; ?>
      </div>
    </div>
    #204375

    Trevor
    Participant

    Since writing that post two years ago, we introduced support for the Post Grid plugin, as creating the code for the results.php files is very time consuming and specific to each site. You can see the guide here:

    https://searchandfilter.com/documentation/3rd-party/post-grid/

    Working with the WooCommerce shop page when that pages shows categories instead of products is more difficult, as our plugin assumes that you want to show products.

Viewing 10 results - 341 through 350 (of 1,224 total)