Ivory Search › Forums › Support › Add Database ID search as a result ?
- This topic has 5 replies, 2 voices, and was last updated 4 years, 1 month ago by Ivory Search.
You must be logged in to create new topic or reply to the topic. Click To Login
- AuthorPosts
- October 1, 2020 at 9:56 AM #5870
If I have an item in a table in my WP database with an ID of 100,
how can I have ivory search return that row, when a users search ‘100’ ?Not sure how to do this,
If this isn’t supported out of the box, can you point me to the file(s) that I should look at to maybe write a function that adds the functionality?Thanks for reading!
- October 1, 2020 at 12:20 PM #5871
I hope you are well today and thank you for your question.
Currently, the plugin does not search IDs but I will implement this feature in the future version of the plugin.
The posts_search function added in the below plugin file handles searching functionality.
https://plugins.trac.wordpress.org/browser/add-search-to-menu/trunk/public/class-is-public.php#L635
Best regards,
Ivory Search Support - October 1, 2020 at 4:26 PM #5872
Thought this would work since it looks like you are just stringing together terms using $wpdb->prepare to create a query.
Any hints on why it’s not working ? it just returns no results. I’m sure if I spend enough time I’ll figure it out but you can probably point me in the right direction and cut my time by a lot. I look forward to this implementation in the future! Also happy to buy support if that includes helping me get this working til the official release.Appreciate your time!
foreach ( (array) $q['search_terms'] as $term2 ) { $term = $f . $wpdb->esc_like( $term2 ) . $l; $OR = ''; $search .= "{$searchand} ("; if ( isset( $q['_is_includes']['search_title'] ) ) { $search .= $wpdb->prepare( "({$wpdb->posts}.post_title {$like} '%s')", $term ); $OR = ' OR '; } // my code starts here if(true){ $cleanTerm = str_replace('%', '', $term); if( 1 == is_numeric($cleanTerm)){ $search .= $wpdb->prepare( "(SELECT * FROM {$wpdb->posts} WHERE ID = %d)", $term ); } }
- October 1, 2020 at 7:43 PM #5875
As said above, I will implement this feature in the future version of the plugin.
If you are not a developer then you can consider hiring a developer to develop it for you. You can hire a developer from any freelance site or WordPress agency.
You can also consider us to develop it for you using the form https://ivorysearch.com/custom-work/
- October 1, 2020 at 8:11 PM #5876
I look forward to it.
I’ll see if I can get it working, appreciate the options given.Have a good one.
- October 2, 2020 at 1:08 PM #5878
Have a fantastic day!
- AuthorPosts
You must be logged in to create new topic or reply to the topic. Click To Login