<?php
// Connect to the WordPress database
$db_host = 'localhost';
$db_user = 'database_username';
$db_pass = 'database_password';
$db_name = 'database_name';
$db_conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
// Check the connection
if ($db_conn->connect_error) {
die('Connection failed: ' . $db_conn->connect_error);
}
// Query the WordPress database
$table_name = 'table_name';
$query = "SELECT * FROM $table_name";
$result = $db_conn->query($query);
// Check the result
if ($result->num_rows > 0) {
// Output the table data
while ($row = $result->fetch_assoc()) {
echo $row['column_name'] . '<br>';
}
} else {
echo 'No data found in the table.';
}
// Close the connection
$db_conn->close();
This code assumes that you have already connected to the WordPress database and that you know the name of the table you want to query. It also assumes that you want to output the value of a column called “column_name” from each row in the table. You can modify the code to suit your specific needs.