Problem with searching in custom post

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Problem with searching in custom post

This topic contains 24 replies, has 2 voices, and was last updated by tim tim 6 years, 8 months ago.

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #5015
    tim
    tim
    Participant

    Hi

    I have the following problem:
    The search is for a custom post (publicaties) with a lot of custom fields. But when I search, the results displayed are only bases on the the custom fields, never the title.

    For example if you search on “recht” you only gets results from custom fields, while “recht” occurs a lot in the titles of these custom posts.

    In the general options > Sources I’ve added the custom post and selected “Search in title”.

    Any ideas?

    Thanks,

    Tim

    #5016
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    The custom field configuration was incorrect.

    On the Frontend search Settings -> Custom fields you have a Uitleenbaar custom field selector created.
    This was using the “_uitleenbaar” custom field, which is not defined on any post, so it didn’t return any results. I have selected the “uitlenbaar” insteand and I have started getting results.

    Some post may not show yet, as the “uitlenbaar” custom field is not yet defined on them. You will have to edit those posts and save them to have the “uitlenbaar” custom field set.

    Best,
    Ernest Marcinko

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


    #5043
    tim
    tim
    Participant

    Great! Thanks for the fast support.

    #5422
    tim
    tim
    Participant

    Hi

    I’m trying to achieve the following:

    When a visitor search for an author (“auteur” is a custom taxonomy), the search field should show the publications by that author. But for the moment only the author himself is displayed in the results, what I not want.

    Can you give me some hint on how to proceed?

    Thanks,

    Tim

    #5423
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    If I understand correctly the authors are taxonomy terms. In this case you can turn ON the “Search In Terms” option, which will look in all terms connected to the posts: https://i.imgur.com/Jmf5YkP.png
    This will return posts related to terms connected to them.

    The option you are using right now will return the taxonomy terms as results, not the posts related.

    Best,
    Ernest Marcinko

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


    #5424
    tim
    tim
    Participant

    Great! Works perfect now.

    Another little (or not) question: is it possible to show in the results the title and the custom taxonomy “auteur” (author)? I’ve already played a bit with this: https://wp-dreams.com/knowledge-base/result-templating/ but I don’t get it working for taxonomy terms.

    Can I just use

    <?php
    // This is the meta key
    $key = 'auteur';
     
    // We only want to do this on posts/pages/custom post types
    if ($r->content_type == 'publicatie') {
      $meta_value = get_post_meta( $r->id, $key, true );
      if ($meta_value != '')
        echo "<div class='author'>" . $meta_value . "</div>";
    }
    ?>
     
    <?php if ($s_options['showdescription'] == 1): ?>
     
        <?php echo $r->content; ?>
     
    <?php endif; ?>

    Or more something like “get_object_taxonomies”

    or not?

    Thanks!

    Tim

    #5428
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Well, I think the upper mentioned code won’t work, because the ‘auteur’ is not a meta field, but a taxonomy term.

    Try something like:

    
    <?php
    // This is the taxonomy
    $taxonomy = 'auteur';
     
    // We only want to do this on posts/pages/custom post types
    if ($r->content_type == 'pagepost') {
      $terms = get_the_terms( $r->id, $taxonomy );
      if (is_array($terms) && count($terms) > 0)
        echo "<div class='author'>" . $terms[0] . "</div>";
    }
    ?>
    
    Best,
    Ernest Marcinko

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


    #5816
    tim
    tim
    Participant

    Thanks, I’m still working on that.

    Now I have the another problem. I’ve worked with some random data to test the search engine (manual inserted). But now I have imported the real data (10 000 records) to my database (with WP All Import Pro). But none of the results are showing up. Any idea what the problem could be?

    Thanks!

    Kind regards,

    Tim

    #5831
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    In case you are using the index table engine, you will have to re-generate the index table to register the imported posts.

    If not, then make sure that the imported items are in published state, the correct post types are selected, and the search cache is not enabled.

    Best,
    Ernest Marcinko

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


    #5867
    tim
    tim
    Participant

    Hi

    I re-generated the index table, but without results. I also tried without the index table and followed your instructions.
    Any ideas?

    Thanks,

    Tim

    #5873
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Is the correct custom post type selected? It looks like the imported data is “publicatie” post type. You will have to select this post type on the General Options -> Sources panel. (and also on the index table options panel, if you are planning to use it)

    Best,
    Ernest Marcinko

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


    #5886
    tim
    tim
    Participant

    Hi Ernest

    In both cases the post type “Publications” is selected. See also in attachment.

    Regards,

    Tim

    Attachments:
    You must be logged in to view attached files.
    #5911
    tim
    tim
    Participant

    Hi

    I think I’ve check out everything. I changed all kind of settings, with and without the index. Even when I add a new “publication” I don’t get results.
    Strange, because I’ve tested the site with 30 records. Everything was working fine then. But then I removed those records and imported the real records (+/- 10 000). Since then no more results…
    If I create the index I get al lot of found keywords; so I thing he picks up the records.

    The site should be operational by the end of this week, so I hope you can help me with this problem?

    Thanks!

    Kind regards,

    Tim

    #5917
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    I found the problem. It’s possibly a bug when calculating the limit of the mysql query. I’m going to release another bugfix update later today, should be available in 48 hours.

    Only a very small modification is needed, you can fix it manually if you want to.

    Open up the wp-content/plugins/ajax-search-pro/includes/search/search_indextable.class.php file and go to lines 446-451, where you should see this:

    /*----------------------- Optimal LIMIT -------------------------*/
    $limit = count(get_option('asp_posts_indexed')) / 2;
    $limit = $limit < 200 ? 200 : $limit;
    $limit = $limit > 2000 ? 2000 : $limit;
    $limit = ($limit * 5) < $searchData['maxresults'] ? ($limit * 5) : $limit;
    /*---------------------------------------------------------------*/

    change that part to this:

    /*----------------------- Optimal LIMIT -------------------------*/
    $limit = count(get_option('asp_posts_indexed')) / 2;
    $limit = $limit < 200 ? 200 : $limit;
    $limit = $limit > 2000 ? 2000 : $limit;
    $limit = ($limit * 5) < $searchData['maxresults'] ? ($limit * 5) : $limit;
    $limit = floor($limit);
    /*---------------------------------------------------------------*/

    Hopefully this will solve the problem immediately.

    Best,
    Ernest Marcinko

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


    #5921
    tim
    tim
    Participant

    Hi

    I’ve just changed the code; but with no results :(.

    Regards,

    Tim

Viewing 15 posts - 1 through 15 (of 25 total)

You must be logged in to reply to this topic.