This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Settings

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #21941
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    1) That is intentional, as each tag is considered as a single word, it will not work with multiple words unfortunately.
    2) This can be very problematic. Currently in WordPress, there is only one way to get the categories in hierarchical order, and that is, when the all the categories are requested.
    A few weeks ago there was a similar request, and this custom code was the closest we could work out together. You should try that, however there is no guarantee it works, and there is no other usable solution either. We even tried to iject the one from the WordPress core, but that does not work without getting all the terms.

    #21956
    kondorkondor
    Participant

    Hi Ernest

    ok, i get your point.

    I implemented the code you suggested for categories hierarchy – seems to work ok.

    1) i found why i am getting results that shouldn’t appear – it is related to a custom term meta that is called ‘cat_seo_text’ which include in its text the search phrase and that is why it showed up even though this category did not have a tag.

    how can i exclude the term ‘cat_seo_text’ from search?

    2) due to comma and multiple keywords issues with additional tags (your plugin built in tags) i took your advice about changing custom fields for tags into simple text field.

    only problem now is that for each tag that i add – it adds +1 to the custom field name :

    i set up a tab containing the repeater fields for tags and it is called “product_search_help_tags”
    each repeater field is called “product_tag_field” – but when i search for ” drag here custom fields you want to use!”, the repeater fields is in array so it adds up 0,1,2,3 (+1 to each new repeater/tag that i add).

    this forces me to keep track each time of the post with biggest amount of tags and add it…

    pls see attached screenshot.

    is there a way to globally search EACH product_tag_field without the need of rechecking how many tags the website owner added?

    THANK YOU VERY MUCH !!! 🙂

    #21958
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    I think both might be possible, but only with major modifications to the code, which means, that an update will overwrite this functionality.

    If you want, I can try arranging these modifications, just wanted you to know, that it won’t be compatible with future versions.

    #21964
    kondorkondor
    Participant

    HI Ernest,

    which one requires major mods? 1 or 2?

    in case you will point me out to these mods – wont i be able to re apply them after update?

    #21975
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    The first one is a bit simpler, it might affect only one line, the second one is more complicated, I’m am not entirely sure. If there are any changes within those core files, then it might not be possible to replicate them after update.

    #21981
    kondorkondor
    Participant

    Hi Ernest,

    ok – so lets handle only first issue only (the 2nd issue i will follow up and add it manually)

    thanks 🙂

    #21986
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okay, so for the first modification, open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-terms.php file, and look for these lines (around line 110):

    if ( $args['taxonomy_terms_search_term_meta'] == 1 ) {
        if ( $termmeta_join == '' )
            $termmeta_join = " LEFT JOIN $wpdb->termmeta tm ON tm.term_id = $wpdb->terms.term_id";
    
        if ( $kw_logic == 'or' || $kw_logic == 'and' || $is_exact ) {
            $parts[] = "( " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like )";
        } else {
            $parts[] = "
               (" . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . " %'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'" . $word . " %'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . "'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " = '" . $word . "')";
        }
    }

    ..and replace them with these:

    if ( $args['taxonomy_terms_search_term_meta'] == 1 ) {
        if ( $termmeta_join == '' )
            $termmeta_join = " LEFT JOIN $wpdb->termmeta tm ON tm.term_id = $wpdb->terms.term_id";
    
        if ( $kw_logic == 'or' || $kw_logic == 'and' || $is_exact ) {
            $parts[] = "(tm.meta_key NOT LIKE 'cat_seo_text' AND " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like )";
        } else {
            $parts[] = "( tm.meta_key NOT LIKE 'cat_seo_text' AND
               (" . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . " %'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'" . $word . " %'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . "'$suf_like
            OR  " . $pre_field . "tm.meta_value" . $suf_field . " = '" . $word . "') )";
        }
    }

    Let me know if you can’t change this, and I will do it via FTP.

    #22056
    kondorkondor
    Participant

    hi ernest,

    thanks, it works great.

    i found out that some other fields are being searched (such as “thumbnail_id”) and if i type a phrase that is included in the id of the thumbnail, it is returned too… which is not ok.

    i tried your code by changing it to: …….tm.meta_key NOT LIKE (‘cat_seo_text’,’thumbnail_id’) AND ” . $pre_fiel……… – but after that i get 0 results…

    is my query modification wrong?

    i also have the following code in functions (so it will return the correct image for result:
    add_filter( “asp_results”, “asp_acf_cf_image”, 1, 1 );

    function asp_acf_cf_image( $results ) {
    // Change this to the ACF custom field name
    $image_field = ‘thumbnail_id’;

    foreach ( $results as $k => &$r ) {
    if ( empty($r->image) && $r->content_type == ‘term’ ) {
    $imgID = get_field($image_field, $r->taxonomy . ‘_’.$r->id);
    $img = wp_get_attachment_url( $imgID );
    // $img = $imgArray[‘url’];
    if ( !empty($img) )
    $r->image = str_replace(“‘”, “%27”, $img);
    }
    }
    return $results;
    }

    but even after removing it from functions, still 0 results…

    any idea what is wrong here / or maybe how can i safely exclude other terms meta fields that might return wrong results (same as ‘cat_seo_text’ you excluded)?

    thanks!

    #22066
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Yes, that query modification is not correct, but you can easily fix it. Instead of this:

    tm.meta_key NOT LIKE ('cat_seo_text','thumbnail_id') AND

    use the NOT IN operator like so:

    tm.meta_key NOT IN ('cat_seo_text','thumbnail_id') AND

    ..and that should do the trick.

    #22137
    kondorkondor
    Participant

    Hi Ernest

    ok, i finally decided to change the query into searching only in specific custom field instead of excluding all the others… works great!

    1) is it possible to count amount of products in product category result and display it? (for example: result = product category “tables” which has 40 products in it) – so can i get the result to show “Tables (40 items in total)” as a result?

    2) i would like to rate your plugin and support since it is truly great, so i would appreciate if you can paste a link where i can rate it 🙂

    thanks!

    #22138
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    1. Well, there is this option. It will display the number of associated items after the term. It is not that fancy, but it should work.

    2. Thank you for your kind words. You can rate the plugin If you like the plugin, feel free to rate it on your codecanyon downloads page 🙂

    #22197
    kondorkondor
    Participant

    Done! million thanks my friend 🙂

    ** I gave a review too 🙂

    #22218
    kondorkondor
    Participant

    just another small question:

    vertical results have a small 20px (approx.) margin from search field and it is controlled by js.

    can you point me out to the correct file? i want to reduce that margin to 0 (search results start right after the search field)

    thanks

    #22230
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    There is actually an option for that here: https://i.imgur.com/723B55d.png
    Try changing that to 0, or even negative values, if it is still not close to the field.

    #22232
    kondorkondor
    Participant

    You cannot access this content.

Viewing 15 posts - 16 through 30 (of 32 total)
  • The topic ‘Settings’ is closed to new replies.