Forums Forums Search & Filter Pro S&F not affecting query_posts() function (how?)

  • This topic has 16 replies, 2 voices, and was last updated 9 years ago by Anonymous.
Viewing 10 posts - 1 through 10 (of 16 total)
  • Trevor
    #58113

    Do you have an args array in the template? Such as here (and see how you filter for S&F):

    $args = array(
      'posts_per_page'   => 6,
      'cat'              => 5,
      'order'            => 'ASC',
      'search_filter_id' => '435'
    );
    query_posts( $args );
    Anonymous
    #58121

    Hi trevor,

    Thanks for replying. Yes I have the args and it is receiving the args I feed it correctly since the query_post is returning results with the correct post type.

    Although, I have not included the arg: search_filter_id

    Is this a custom arg by S&F? If yes, are you aable to walk me through?

    Trevor
    #58131

    Yes, it is a custom arg for S&F. You simply set the ID number from the shortcode of the form to have wp_query use it to filter.

    Anonymous
    #58133

    Oh my, Thanks trevor!
    Is this documented somewhere? I’d like to know more about this arg and what other arguments I can use.

    Please get me informed.

    Thanks.

    Trevor
    #58141

    Not sure if it is documented. Ross, the developer, tends to put things in and often documents them on GIST (username is rmorse), or the plugins docs here, or in the faq’s.

    Trevor
    #58143

    Let me know if you get it fixed and if I can close the thread?

    Anonymous
    #58354

    Hey Trevor,

    I’ll be doing the testing today, I’ll get back when I’ve applied the fix.

    Thanks

    Anonymous
    #58378

    Hi Trevor,

    I have applied the fix you have given me, but the search and filters still do not seem to take any effect.

    Here’s a snippet of my code:

    $car_query_paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    	$car_query_args = [
    		'paged' => $car_query_paged,
    		'post_type' => 'car',
    		'posts_per_page' > 20,
    		'search_filter_id' > 19446,
    	];
    	$cars_query = query_posts($car_query_args);
    
    	print_r($cars_query);
    
    	?>
    		<div class="car-search-container">
    			<div class="car-search">
    				<?php echo do_shortcode('[searchandfilter id="19446"]'); ?>
    			</div>
    		</div>
    
    		<div class="search-results-container">
    		<!-- Loop for displaying results here (Working) -->
    
    

    Please let me know if I am doing something wrong.

    Thanks!

    Trevor
    #58382

    The code should not be different from a normal page. It does not need a special container for the results. Other an inserting the form itself and the extra argument, the template code should be the same as an archives page template. You are using the ‘As an Archive’ Display Results method?

    Trevor
    #58392

    Ross, the developer, gave me some advice for you.

    Your loop (which we can’t see) I think may be using the wrong syntax – like $cars_query->results, whereas query_posts replaces the global query

    So your loop might be

    while ( $cars_query->have_posts() ) : $cars_query->the_post();
    

    But it should be

    while ( have_posts() ) : the_post();
    

    If you want the query in a var, you should use new WP_Query() with the same args.
    Just guessing here

Viewing 10 posts - 1 through 10 (of 16 total)