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

Viewing 10 posts - 1 through 10 (of 17 total)
  • Anonymous
    #58103

    Hi,

    Your plugin is undeniably good with the form builder. However, with a little customization, I’ve become a little lost. I am trying to create my own theme using Cherry Framework 4. I am working to create a WordPress template for a custom search page. The template is not a copy of search.php but a normal WordPress template where I would like to run query_post() function to override the default query or AKA main loop. The changes I wanted to make with the main loop was the post type being queried. The query is returning items successfully, but without the filters taking effect. Am I missing something?

    The page is a normal page with the template applied. The reason for using a normal page is I’d like to use the layout options for the sidebar Cherry Framework comes with.

    So the question is: For the purpose of custom theme-templates, what is the proper way doing a query where S&F is able to apply the filters?

    Thanks,
    J – Lead Developer

    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?

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