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 'current_query'

Viewing 10 results - 11 through 20 (of 374 total)
  • Author
    Search Results
  • #266668

    Trevor
    Moderator

    Yes, you would need to edit the results.php file, as indicated here (changing the ID shown to match that of your form):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(11690)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // the current resuts.php code here (ALL the code from the if ( $query->have_posts() ) line and onwards)
    }
    #265842

    In reply to: Pagination


    Trevor
    Moderator

    I think it should look like this:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(11690)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div class="farmacia">
    			<h2 class="nome-farmacia"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			<?php the_content(); ?>
    			
    
    			
    		</div>
    		
    		<hr />
    		<?php
    	}
    }
    #265838

    In reply to: Pagination


    Edda Puglisi
    Participant
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(11690)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
      // the current resuts.php code here
    }
    
    	?>
    	
    	
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div class="farmacia">
    			<h2 class="nome-farmacia"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			<?php the_content(); ?>
    			
    
    			
    		</div>
    		
    		<hr />
    		<?php
    	}
    	?>
    

    So you see it correctly?

    #265810

    In reply to: Pagination


    Edda Puglisi
    Participant

    Thanks for the help, I tried, the results.php page is composed as follows:

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

    ?>

    <?php
    while ($query->have_posts())
    {
    $query->the_post();

    ?>
    <div class=”farmacia”>
    <h2 class=”nome-farmacia”>“><?php the_title(); ?></h2>
    <?php the_content(); ?>

    </div>

    <hr />
    <?php
    }
    ?>

    If I go to https://www.staging2.biotechmed.it/farmacie/ it shows me all the results… My client does not want that someone can easily see all the results and download all the names.

    Another question, is it possible to search only in two specific fields and ignore the others in the search?

    #265739

    In reply to: Pagination


    Trevor
    Moderator

    I see that you are using our Shortcode method …

    … in which case you should follow the ‘guide to customising’:

    https://support.searchandfilter.com/documentation/search-filter-pro/search-results/using-a-shortcode/

    Once you have a copy of the results.php file in a search-filter sub-folder of your theme, you can edit that file, like this (leave the PHP comments at the top outside and before this code):

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

    This code will prevent any results from showing UNTIL a search has been made. If you need to modify it a little, at least it should give you some ideas.

    You can show ALL results (no pagination) if you set in the form on the General settings tab the ‘Results per page’ to -1.

    The you need to remove the pagination output from the results.php code, so delete the two blocks that look like this (one before the loop, one after):

    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>
    #265638

    Trevor
    Moderator

    So, using our Shortcode method …

    … in which case you should follow the ‘guide to customising’:

    https://support.searchandfilter.com/documentation/search-filter-pro/search-results/using-a-shortcode/

    Once you have a copy of the results.php file in a search-filter sub-folder of your theme, you can edit that file, like this (leave the PHP comments at the top outside and before this code):

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

    Trevor
    Moderator

    If you are using Ajax, you need these filter labels inside the Ajax Container. If you want them to be shown elsewhere on the page, you still have them, but hidden with CSS, inside that Ajax Container, but use jQuery to copy and paste them to where they will show after our sf:ajaxfinish event has triggered.

    You will also need to be using a PHP template for the page. It will be much harder (or not possible at all) if you are using a page builder or post grid plugin/widget.

    It will require some coding for which I can point you in the direction of snippets, but I cannot help you write the code, sorry, as this is not within the scope of our support.

    To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    … and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array

    This particular post may help:

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

    I would add that we plan to make this far easier in V3 of our plugin, due in a few months.

    #263893

    Trevor
    Moderator

    Print out the entire search filter to the page array to see if they are in it (if they are, you can work out where in the array they are). This post should help:

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

    #263439

    Nathan Holmes
    Participant

    Hi, I’m having some trouble getting the ajax event hooks to work.
    I added the code from the FAQ page for sf:ajaxfinish, but I’m not seeing anything in the console log.
    See code below. Does anything stand out as to why this would not be working?

    Thanks.

    
    <?php
    
    /**
     * The template for displaying search results pages.
     *
     * @package understrap
     */
    
    // Exit if accessed directly.
    defined('ABSPATH') || exit;
    
    get_header();
    
    $container = get_theme_mod('understrap_container_type');?>
    
    <div class="wrapper contentPadding" id="search-wrapper">
    
    <link rel="stylesheet" href="<?php echo get_site_url();?>/wp-content/themes/InyoBlogTheme/dist/bricklayer.min.css">
    <script src="<?php echo get_site_url();?>/wp-content/themes/InyoBlogTheme/dist/bricklayer.min.js"></script>
    
    	<div class="<?php echo esc_attr($container); ?>" id="content" tabindex="-1">
    		
    	<div class="row">
    	<!--Display sub navigation partial view -->
    		<?php get_template_part('partials/navtabs'); ?>
    	</div>
    	<div id="test">This is a test</div>
    		
    		<!--Display Search & Filter Widget -->
    		<?php if (is_active_sidebar('search-bar')) : ?>
    							<div id="search-bar" role="complementary">
    								<?php dynamic_sidebar('search-bar'); ?>
    								
    							</div>
    						<?php endif; ?>		
    
    		<header id="search-title">
    			
    			<?php
    			global $searchandfilter;
    			$sf_current_query = $searchandfilter->get(102003)->current_query();	
    			$args = array(
    				"str" => '%2$s'
    			);
    
    			if (!$sf_current_query->get_search_term()=="") {
    			echo '<h3>Search Results for:<span> "' . $sf_current_query->get_search_term() . '"</span></h3>'; 
    			}
    
    			?>
    			
    		</header><!-- .page-header -->
    
    		<div class="row">
    
    			<!-- Do the left sidebar check and opens the primary div -->
    			<?php get_template_part('global-templates/left-sidebar-check'); ?>
    
    			<main class="site-main" id="main">
    
    				<?php if (have_posts()) : ?>
    
    					<div class="bricklayer" id="my-bricklayer"> 
    					<?php /* Start the Loop */ ?>
    
    					<?php while (have_posts()) : the_post(); ?>
    						<?php
    							//Display search results based on content type. 
    							//To change how different content types are displayed in search, edit the content-search loop template.									
    							get_template_part('loop-templates/content', 'search');
    									
    						?>
    						
    					<?php endwhile; 
    
    					wp_reset_postdata();
    
    					?>
    
    					</div><!--Bricklayer-->
    						
    				<?php endif; ?>
    									
    			</main><!-- #main -->
    
    			<!-- The pagination component -->
    			<div class="pt-3">
    				<?php 
    				understrap_pagination();
    		
    				?>
    			</div>
    
    			<!-- Do the right sidebar check -->
    			<?php get_template_part('global-templates/right-sidebar-check'); ?>
    
    		</div><!-- .row -->	
    
    	</div><!-- #content -->
    
    </div><!-- #search-wrapper -->
    
    <script>
    	var bricklayer = new Bricklayer(document.getElementById('my-bricklayer'));
    
    	$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
    		console.log("ajax complete");
    		//do or stop your animation
    	});
    </script>
    
    <!--Display bottom advertisment-->
    <?php get_template_part( 'partials/poolparts-ad'); ?>
    
    <?php get_footer(); ?>
    

    Trevor
    Moderator

    One too many brackets (after the is_filtered), OR paste this corrected line instead:

    if ($sf_current_query->is_filtered()||($sf_current_query->get_search_term()<>"")||is_page(25640)) {

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