• Hi,

    I would like to know if it’s possible for the standard search function (or an equivalent plug) to search through two databases.

    I have set up a standard wordpress website which has an additional database holding information local businesses. I can build specific templates to access these second database but I would also like it so that if a user uses the ‘search’ functionality it looks for the string in the core database as well as the second database. Is this possible?

    BTW – I am happy writing PHP so having to do code not a problem.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yes it is possible.
    The present search facility will be your guide and template.
    You could do it in your own plugin, but equally well in “functions.php” of your child theme.
    Make the search box invoke your own code which searches both databases.

    Thread Starter baobabit

    (@baobabit)

    Hi Ross,

    Thanks for the suggestion. If I understand this correctly, you’re suggesting that I create my own script that searches the WP database as well as my bespoke database. I have to confess, I hadn’t thought of that and was hoping the WP version could be persuaded to search both databases. Following your suggestion, now that I think about it, my idea was obviously not going to work because it wouldn’t know the table names, etc. Doh!

    I may take a short-cut and replace the WP search with a Google Site search and make sure my site has a page outputting the relevant content from the bespoke database.

    Your suggestion definitely clarified things for me so thank you.

    Adam

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

The topic ‘Can WordPress search search two databases’ is closed to new replies.