I want to customize default search query in wordpress

I want search default data in another database.

Now I have 2 databases , one for wordpress and another base with copy of wp_posts content.

I want to change search query to secondary database.

How to do it via function?


I believe you are looking for this

$mydb = new wpdb('username','password','database','localhost');
$rows = $mydb->get_results("select Name from my_table");
echo "<ul>";
foreach ($rows as $obj) :
  echo "<li>".$obj->Name."</li>";
echo "</ul>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.