• MacGyver_

    (@macgyver_)


    I’ve been google-ing a lot and cannot find an example for searching a custom table and show it into the wrdpress searchresults. The custom tables has a identification for posts (post_id)

    Can anyone direct me to the correct information ?

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • Kr0nZ

    (@kr0nz)

    you mean something like this?

    global $wpdb;
    $test = $wpdb->get_results(
        $wpdb->prepare("SELECT * FROM testtable"),
        ARRAY_A
    );
    foreach ($test as $testrow) {
       $therow = get_post($testrow['postid']);
       print_r($therow);
    }

    Thread Starter MacGyver_

    (@macgyver_)

    Is there a way to include this in the search of standard WordPress ?

    Thread Starter MacGyver_

    (@macgyver_)

    to be exact : if i use the standard search of wordpress i want the output of the custom table to be in the reults.

    Kr0nZ

    (@kr0nz)

    Theres always a way when you have access to the source code

    But off the top of my head you would need to do a mysql join in the query that the search form uses.
    Unfortunately Ive never done a mysql join so not sure how to go about it

    Thread Starter MacGyver_

    (@macgyver_)

    extra (custom) table contains the post_id so the record(s) can be linked the a particular post.

    Thread Starter MacGyver_

    (@macgyver_)

    Are there plugins witch incorporate their data into the search of wordpress ? maybe i can use these plugins as an example.

    Thread Starter MacGyver_

    (@macgyver_)

    i just found http://codex.wordpress.org/Custom_Queries
    Theres a section covering Keyword search in plugin table.

    however : i tried to follow the directions (example).
    It is not clear to me where to put the code.
    can anyone explain how this works ?

    Thread Starter MacGyver_

    (@macgyver_)

    Still no awnser from anyone. Im I really the first one to make wordpress search custom tables ?? Theme must be someone with some search experience

    Moderator bcworkz

    (@bcworkz)

    I have no experience with custom tables, but the code examples from the Custom Queries page can be placed in either the functions.php file of your theme or child theme, or you can place the code in your own plugin.

    For more complex SQL queries, I prefer to use $wpdb methods that accept raw SQL query syntax. It’s easier to find generic SQL query examples that work than trying to figure out what WP_Query does with your arguments.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Search custom tables’ is closed to new replies.