Allow search through "TermMeta" Database Table

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 samyagshah 4 years, 1 month ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #18541
    samyagshah
    samyagshah
    Participant

    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

    #18545
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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 :)


    #18547
    samyagshah
    samyagshah
    Participant

    Thanks 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.

    #18564
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #18584
    samyagshah
    samyagshah
    Participant

    Thanks. 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 4 years, 1 month ago by samyagshah samyagshah.
    • This reply was modified 4 years, 1 month ago by samyagshah samyagshah.
    #18599
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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
    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.

    Best,
    Ernest Marcinko

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


    #18608
    samyagshah
    samyagshah
    Participant

    Thanks. 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” ?

    #18614
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You 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 :)


    #18616
    samyagshah
    samyagshah
    Participant

    Ok Thanks. Appreciate your help.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.