Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Modify WHERE clause
This topic contains 8 replies, has 2 voices, and was last updated by Ernest Marcinko 2 years, 6 months ago.
- AuthorPosts
- November 29, 2020 at 8:22 am #30410
Hello
I have a project with huge customization.
I am using these filters:
add_filter(‘posts_join’, ‘custom_filter_posts_join’ );
add_filter( ‘posts_where’, ‘custom_filter_posts_where’, 10, 2 );Is posible to do that with your API of filters and Hooks? As I readed is not so clear, I think is not posible…
Thanks
Héctor-
This topic was modified 2 years, 6 months ago by
hbb97.
November 30, 2020 at 10:28 am #30421Hi Héctor,
You can add fields to the final query, there are multiple ways, these are not documented yet unfortunately. I recommend using these hooks:
$add_select = apply_filters('asp_cpt_query_add_select', '', $args, $phrase, $phrase_array); $add_join = apply_filters('asp_cpt_query_add_join', '', $phrase, $phrase_array); $add_where = apply_filters('asp_cpt_query_add_where', '', $phrase, $phrase_array);
You can add a hook to them like so:
Best,add_filter('asp_cpt_query_add_join', 'my_asp_cpt_query_add_join', 10, 4); function my_asp_cpt_query_add_join($query, $args, $phrase, $phrase_array) { global $wpdb; // Return the join query you want return "LEFT JOIN ..."; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 30, 2020 at 6:44 pm #30429Great!!
That filters are good for Search Engine = Regular Engine.
Is something equivalent for Search Engine = Index Table Engine?Thanks
HéctorDecember 1, 2020 at 9:54 am #30437Sure, sorry I forgot about that:
apply_filters('asp_it_query_add_select', ''); apply_filters('asp_it_query_add_join', ''); apply_filters('asp_it_query_add_where', '');
Please note that the index table engine uses a completely different query on a different tabe, so to get the fields you need I recommend checking line 350-398 in wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-indextable.php
-
This reply was modified 2 years, 6 months ago by
Ernest Marcinko.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 1, 2020 at 11:58 am #30446Is posible to get inside that filters, $args variable, or search phrase?
December 1, 2020 at 1:44 pm #30452Hm, I think not without changes to the core. It looks like I forgot to add those arguments to the filters.
Anyways, I will definitely fix that in the upcoming release, but until then, you can fix that by replacing one of the plugin files:1. Open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-indextable.php file on your server.
2. Replace it’s contents with this
3. SaveNow you should be able to use the same arguments as on the regular engine (query, $args, $phrase, $phrase_array)
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 2, 2020 at 4:14 pm #30466Hello
Going to test filters for Indexed Table Search, but:
Is posible to add registers at Index Creation?
Are some actions or filters involved at that point?Thanks
HéctorDecember 3, 2020 at 7:40 am #30470With this filters it works for me:
$values = apply_filters( ‘asp_post_custom_field_before_tokenize’, $values, $the_post, $field );
Thanks!
HéctorDecember 3, 2020 at 9:33 am #30472You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This topic was modified 2 years, 6 months ago by
- AuthorPosts
You must be logged in to reply to this topic.