How To Make Connection To WordPress Data Base In A Plugin?
Option 2 is to use a database. This option is best for large amounts of data. WordPress already uses a database, one based on SQL. You will need access to the database and you’ll need to add a table (or multiple) and populate it with your data. Then you need to use SQL queries to query the data. This will also involve a client side script managing the data coming from the server.
We found the answer my self. First open your wp-config.php and check the bottom of file that Is that contain the below code?.
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
If yes then add the below code to make the connection in your plugin PHP files to connect with wp-config.php file that contain Database Name, Database UserName, Database Password, Database Host… …
require_once(ABSPATH . 'wp-config.php');
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
And you will get connection to WordPress database…