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 8 years, 2 months ago by Anonymous.
-
Anonymous(Private) September 15, 2016 at 4:35 pm #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 DeveloperAnonymous(Private) September 15, 2016 at 4:48 pm #58121Hi 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?
-
AuthorPosts