I have created a table in my WordPress database. Now, WordPress gets all its data about different posts and pages from the database. This means that WordPress always connects to database automatically without theme developers writing any code.
I want to get information from a table I added to the database inside the
header.php file of my theme. My question is do I need to create a WordPress database connection by loading all the files like
require_once(__DIR__."/../wp-load.php"); require_once(__DIR__."/../wp-config.php"); $connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
Or I can use the existing database connection. If I can use the existing database connection, how do I do that?