- This topic has 2 replies, 3 voices, and was last updated 5 years, 1 month ago by .
These forums are now closed and remain for historical purposes.
None of the content applies to the new version 3. For support, get in touch via our contact form.
Forums › Forums › Search & Filter Pro › Searchandfilter and external database
Tagged: external database, external query, search and filter
Hi, we are developing a master website that has the master data. Additionally, there are satellite websites that read data from master website. We use your plugin searchandfilter, and we need to connect searchandfilter of satellite websites to master data, so we need to do an external database connection with this method:
function get_maps( $data ) {
$args = array (
‘search_filter_id’=>27169,
‘posts_per_page’=>-1,
‘numberposts’ => -1,
);
$query = new WP_Query($args);
/*here I get the results of the query*/
return $data;
}
add_action( ‘rest_api_init’, function () use () {
register_rest_route( ‘search-and-filter/v1’, ‘/map/’, array(
‘methods’ => ‘GET’,
‘callback’ => ‘get_maps’
)
);
});
Can you orientate us if there is a good way to do this please?
Regards,
Mariano
Hi Rafa
Although I’ve never tried this it looks like it’s possible, see here:
https://devblog.kommigraphics.com/wordpress/connect-another-wp-database-use-wp_query/
Thanks
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!
More information about our Cookie Policy