Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Allow search through "TermMeta" Database Table
This topic contains 8 replies, has 2 voices, and was last updated by samyagshah 5 years, 5 months ago.
- AuthorPosts
- July 2, 2018 at 4:01 am #18541
Hi There,
I hope you had a great weekend. I am really enjoying setting up the Ajax Search Pro Plugin. I have hit a small glitch though. From what I can see I am unable to locate the option to allow search through “TermMeta” database table.
I have created one Custom Taxonomy of which meta keys are store in database table “TermMeta”. I want to allow search through this defined meta keys.
Thanks
July 2, 2018 at 9:18 am #18545Hi!
Thank you for your kind words!
Unfortunately the term meta search is not yet implemented. However I am releasing a new minor update in the the upcoming days, and this should not be too complicated to implement.
I will make sure this is included in the next release.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 2, 2018 at 9:40 am #18547Thanks for quick reply.
Actually its one of the must have feature for my website. Any quick work around?Any filter or action? I just want meta key named “_wcbs_author_sub_title” to be included in search.
In source2.php I found following code in commented form:
<!-- ON HOLD - term meta is not used yet widely ACF uses wp_options table to store taxonomy term meta... <div class="item"> <?php //$o = new wpdreamsTermMeta("search_term_meta", "Search in term meta?", $sd['search_term_meta']); //$params[$o->getName()] = $o->getData(); ?> </div> -->
Thanks.
July 3, 2018 at 10:27 am #18564Hi,
That is not going to do it, it is only the visual option, the query needs to be implemented as well. I might have a possible solution, it appears to be working on my test servers. Please follow the instructions below:
1. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-terms.php file on your server, and scroll to lines 186-188, which should be these:
$add_select = apply_filters('asp_term_query_add_select', ''); $add_join = apply_filters('asp_term_query_add_join', ''); $add_where = apply_filters('asp_term_query_add_where', '');
..now, change those lines to this:
2. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
If everything goes well, the the term meta table should be searched as well.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 4, 2018 at 11:13 am #18584Thanks. Its working. Appreciate your help.
Two quick questions:
1. My Primary keyword logic is “AND with exact word matches“. What changes needs to be done in above provided “where clause” in order to make it compatible with it?
2. I am using “Index Table engine.” I want to index couple of meta keys stored in TermMeta table. How can achieve this?
Thanks.
-
This reply was modified 5 years, 5 months ago by
samyagshah.
-
This reply was modified 5 years, 5 months ago by
samyagshah.
July 5, 2018 at 7:03 am #18599Hi,
1. Try this one instead of the previous codes:
2. Might be possible actually. But please note, that this indexes the term meta with the associated posts, not with the terms, as the index table only supports custom post types.
Step 1
You will have to make a direct modification in one of the plugin core files to include an additional filter.
– Open up the wp-content\plugins\ajax-search-pro\includes\classes\etc\indextable.class.php file
– Find line 750, which should be this:$terms = wp_get_post_terms( $the_post->ID, trim( $taxonomy ), array( "fields" => "names" ) );
– Make a new line below it, and put this there:
$terms = apply_filters("asp_index_terms", $terms, $taxonomy, $the_post);
– Save & Close
Step 2
Best,
Try the code below in the functions.php file in your theme directory. Don’t forget to change the $meta_keys and the $taxonomies array with the meta key names to look for, and the taxonomy names that should be affected.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 6, 2018 at 7:27 am #18608Thanks. Its working. Appreciate your help.
One last question: What changes needs to be done in above provided “where clause” if I change My Primary keyword logic from “AND with exact word matches“ to “AND” ?
July 6, 2018 at 9:54 am #18614You are welcome.
In that case, this variation should do the trick:
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 6, 2018 at 9:59 am #18616Ok Thanks. Appreciate your help.
-
This reply was modified 5 years, 5 months ago by
- AuthorPosts
You must be logged in to reply to this topic.