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
- REST API – filters not working inside plugin class
- Switch from wp-cron to a server cron job
- Asynchronous request in wordpress
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- Make plugin php file called directly aware of WordPress?
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- Way to send multiple values for column to MySQL?
- Using meta_query in a WP_Query not working for numbers properly
- Calling a save function from a “submit” button
- Wp Debug Enabled True Notices and Warning
- How to call external functions from a PHP script in a WordPress plugin?
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- Next Previous Post in wordpress with previous / next link with title?
- Delete data from custom table when deleting a post
- Different registration form for different roles
- More gentle way to hook WordPress custom url
- Apply html elements in php statement
- How to display results from a data table with an encrypted user id?
- How to add custom function to pluggable.php
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- Pagination not working
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- Seperate plugin and theme files
- can’t unzip file
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- Woo-commerce Update price as a Bulk from My offline software export
- wc_get_template_part doesnt display the content [duplicate]
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- save_post_product action not firing
- Rename a folder via HTML POST request
- How to change “Read More” text?
- How to translate to spanish wordpress hardcoded content/files?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- update_post_meta is not working for me when I use e.preventDefault for update button
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- 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?
- Getting all woocommerce products from REST API call in plugin
- is it possible to fetch data from a remote api while admin is writing a new post?
- WordPress plugin blog creation
- Problem with wordpress has_action() function
- Offering a freemium plugin (a free version + paid version)
- Using id to show item
- add tags to wordpress post using REST API
- Multiple image selection custom widget
- implement checkbox or toggle switch in plugin code
- 500 Internal server error wp_handle_upload_prefilter
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- Create a form and have custom menu display based on user answers?
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Modifying server’s response to API endpoint
- Is it possible to custom set query for a WordPress REST API response?
- Generate and send ICS file through WordPress
- Get post content inside plugin class method
- Is admin section completely customizable in terms of styling?
- Woocommerce list variations that are added already to cart in Single Product
- How to use information from the database in the front-end?
- submit form data to wordpress existing database table using my plugin
- WordPress Admin sub-level menu issue
- WordPress PHP error getting posts from another wordpress blog
- Change pricing in Woocommerce based on Category and Product [closed]
- register_activation_hook doesn’t fire at all
- Plugin communication between sites that use it?
- Passing ajax variable to more than one wordpress plugin function
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- Problem with conditional woocommerce custom checkout field
- Form tries to download a file on submit
- Populate select option with JSON file
- WordPress not displaying information on post sent from custom admin form
- insert multiple entries in database using a loop issue
- How to insert variable which contain array value in wp_options table?
- Displaying friend’s posts only
- Theme editor removes backslashes
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Trending Tags based on post views
- Shortcode in a blog post, footer and related products stop working
- Autoloading a PHP class – working outside, but not inside WordPress plugin
- Plugin Hook: Get posts