-1

I'm trying to select all the data from within the post_content column in the wp_posts table in WordPress so I can export/import it into a new database. Somehow this content didn't properly make it from the old to new database.

  • 1
    SELECT post_content from wp_posts ? – nothingtosee Oct 11 '14 at 0:56
  • Holy crap, is it really that easy? I had no idea. Yeah, that seems to have done it. Thank you! – micah Oct 11 '14 at 1:08
0

Use This Script

<?php
$servername = "localhost";
$username   = YOUR_USER;
$password   = YOUR_PASSWORD;
$dbname     = YOUR_DB_NAME;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$a1 = ($_GET['id']); 
$sql = "SELECT post_content FROM `wp_posts` where ID='$a1'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row["post_content"];
    }
} else {
    echo "0 results";
}
$conn->close();
?>

Don't Forget To Change Your Database Details Above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.