Reply To: Changing priority of content types for results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Changing priority of content types for results Reply To: Changing priority of content types for results

Ernest Marcinko
Ernest Marcinko


I’m currently working on a solution to make a search faster as ever, it might take a couple of days to finalize, but the initial results are promosing.

In the meantime, the best way to get the search faster is reducing the results count (on the general options tab, “Max results”) from 30 to around 10. I forgot to change it when releasing the new version. 30 is a little bit too much. The caching is only active for phrases, that have already been searched. The most common reason of the slow search is however the images. All of the images are created on the fly, and that prodecure is a bit slow until the images aren’t searched at least once.
By reducing the result count to 10 lowers the amount of images processed on the fly, it should speed up the search almost 2-3 times.
The ‘Max result’ setting is going to be lowered to 10 results in the next verions 🙂

As for your request, I think it might be possible, but you will need to edit one file for this.
Open up the plugins/ajax-search-pro/includes/search_content.class.php file and go to like 195, you should see this:

$querystr .= " ORDER BY relevance DESC, ".$wpdb->posts.".".$orderby."

This code is responsible for the final ordering of the search results. Because you want to order by post_type first, you must change the line to this:

$querystr .= " ORDER BY $wpdb->posts.post_type DESC, relevance DESC, ".$wpdb->posts.".".$orderby."

or this:

$querystr .= " ORDER BY $wpdb->posts.post_type ASC, relevance DESC, ".$wpdb->posts.".".$orderby."

depending on your post type name. One of the solutions should work 🙂

Let me know how it goes!

Ernest Marcinko

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