You can access another database using the wpdb
class and its associated methods. You will need to instantiate a new connection to the other database using the appropriate credentials. Here is the basic code to set up the new connection and query the database:
$mydb = new wpdb('username','password','database','localhost');
$rows = $mydb->get_results("<your SQL query here>");
Replace the parameters to the wpdb()
method as required and construct the necessary query for get_results()
.
Related Posts:
- wp_remote_get() returns 403 while file_get_contents() does not
- Redirect to another page using contact form 7? [closed]
- adding dynamic/multiple slug values in ‘option_none_value’
- Showing how many times is plugin activated or deactivated
- Can’t access 3rd party API, code works on local server but not on wordpress
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Customizing subject in comment notification e-mails
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- WordPress widget / plugin….fields not appearing in my widget
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Custom Shipping method not showing in checkout
- REST-API: extend media-endpoint
- How use %like% in sql statement wordpress
- Plugin exceeds memory limit
- Write to / remove from default .htaccess file from plugin?
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- How to generate video out of images via WordPress plugin
- How can I get WordPress to save comments in markdown format?
- How to ‘clone’ a wp plugin to make small changes
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Edit Yoast SEO breadcrumbs output [closed]
- Redirection of users away from wp-admin (but not administrators)
- code is working properly in Core PHP but writing coding in WordPress
- How to modify WCMP Rest API response?
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery
- Create a plugin from within WordPress
- Class variables not correct on page
- Duplicate results are displayed in a custom plugin [closed]
- Why is my custom post type not being activated on plug-in activation?
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- How to create WordPress custom end point with multiple parameters?
- How to redirect to same page after form submission
- Return multiple values in a shortcode attribute
- How do I add $_SESSION[”] to my wordpress page?
- Plugin onclick button activate other plugin
- I receive taxonomy id
- Loop in elementor custom widget not working
- Built a second plugin but it overwrote the first one
- Creating a functionality plugin to edit seriously simple podcasting
- Asynchronous request in wordpress
- Make plugin php file called directly aware of WordPress?
- Next Previous Post in wordpress with previous / next link with title?
- Different registration form for different roles
- Apply html elements in php statement
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- Pagination not working
- can’t unzip file
- Woo-commerce Update price as a Bulk from My offline software export
- how to display recent post by category on home page
- How to Join wp_posts & wp_postmeta table using custom query
- Allow a particular user to access a particular plugin?
- Change plugin descriptions
- The Build menu theme is frozen with the wordpress theme
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- Rename a folder via HTML POST request
- How to translate to spanish wordpress hardcoded content/files?
- update_post_meta is not working for me when I use e.preventDefault for update button
- working code, not working – Plugin Dev
- SimpleXML is not working with xml response from external api
- How to use Datatable with Ajax when creating plugin on WordPress?
- add tags to wordpress post using REST API
- Multiple image selection custom widget
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- How to use information from the database in the front-end?
- register_activation_hook doesn’t fire at all
- Plugin communication between sites that use it?
- My ajax request don´t work and return 0
- Form tries to download a file on submit
- Populate select option with JSON file
- insert multiple entries in database using a loop issue
- How to insert variable which contain array value in wp_options table?
- Theme editor removes backslashes
- Trending Tags based on post views
- Plugin Hook: Get posts
- Plugin Breaking WordPress Login
- How to get site homepage from plugin?
- WP-Snap too slow (caused by WP_Query?)
- WordPress Meta Query: Relation is not working correctly
- Checking url from plugin [duplicate]
- Undefined variable _POST
- Extend WordPress REST API with Scheme Pro Plugin
- Unable to show 4 products in a row
- What is the source outline for a basic word press plugin?
- Submit posts in two different post types with the same form
- wordpress Ajax success doesn’t return the value
- How can I send api calls from my plugin?
- Displaying Category Feature image on loop
- Is it possible to create post in wordpress using postman?
- How to trigger plugin migration code when plugin updates?
- How to Save Category and Delete Category in same Function