Forums › Forums › Search & Filter Pro › S&F not affecting query_posts() function (how?)
Tagged: custom template, query
- This topic has 16 replies, 2 voices, and was last updated 9 years ago by
Anonymous.
-
Anonymous(Private) September 15, 2016 at 4:48 pm #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?
Anonymous(Private) September 16, 2016 at 10:31 am #58378Hi 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(Private) September 16, 2016 at 11:27 am #58382The 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(Private) September 16, 2016 at 11:43 am #58392Ross, 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 querySo 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 -
AuthorPosts