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 7 years, 10 months ago.
- AuthorPosts
- June 15, 2015 at 9:39 pm #5015
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
June 16, 2015 at 9:08 am #5016Hi!
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 :)
June 18, 2015 at 8:18 am #5043Great! Thanks for the fast support.
July 27, 2015 at 2:39 pm #5422Hi
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
July 27, 2015 at 5:48 pm #5423Hi!
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 :)
July 27, 2015 at 6:48 pm #5424Great! 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
July 29, 2015 at 10:05 am #5428Hi!
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:
Best,<?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>"; } ?>
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
September 7, 2015 at 7:35 pm #5816Thanks, 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
September 9, 2015 at 8:57 am #5831Hi!
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 :)
September 10, 2015 at 8:42 pm #5867Hi
I re-generated the index table, but without results. I also tried without the index table and followed your instructions.
Any ideas?Thanks,
Tim
September 11, 2015 at 9:35 am #5873Hi!
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 :)
September 11, 2015 at 1:12 pm #5886Hi 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.September 14, 2015 at 9:20 am #5911Hi
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
September 14, 2015 at 10:47 am #5917Hi!
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 :)
September 14, 2015 at 11:46 am #5921Hi
I’ve just changed the code; but with no results :(.
Regards,
Tim
- AuthorPosts
You must be logged in to reply to this topic.