Reply To: Display search result in my theme's search.php template

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Display search result in my theme's search.php template Reply To: Display search result in my theme's search.php template

#12930

Ernest Marcinko
Keymaster

Hi,

I think there might be actually two possible causes:

1. Make sure that the search override is enabled: https://i.imgur.com/viRLn6S.png
In this case however I don't think that is going to solve the issue by itself.

2. The issue with the code is that there is a duplicate query executed, which cannot be overridden by ajax search pro, on this line:

$the_query = new WP_Query( $args );

This is not neccessary, as when the execution gets to search.php file, the search results are already parsed, no need to query again.
Simply the have_posts() and the_posts() calls should be made, without the query object.

I've made a correction to your code, but I have not tested it, please be careful. This is what it should look like:

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)