Add Database ID search as a result ?

Ivory Search Forums Support Add Database ID search as a result ?

Viewing 4 reply threads

You must be logged in to create new topic or reply to the topic.

  • Author
    Posts
    • #5870
      chris ortega
      Participant
      • Topics: 1
      • Replies: 2

      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!

    • #5871
      Ivory Search
      Keymaster
      • Topics: 0
      • Replies: 1,735

      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

    • #5872
      chris ortega
      Participant
      • Topics: 1
      • Replies: 2

      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 );
                      }
                  }
      
      
    • #5875
      Ivory Search
      Keymaster
      • Topics: 0
      • Replies: 1,735

      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/

      • #5876
        chris ortega
        Participant
        • Topics: 1
        • Replies: 2

        I look forward to it.
        I’ll see if I can get it working, appreciate the options given.

        Have a good one.

    • #5878
      Ivory Search
      Keymaster
      • Topics: 0
      • Replies: 1,735

      Have a fantastic day!

Viewing 4 reply threads

You must be logged in to create new topic or reply to the topic.