Categories
Uncategorized

New WP 2.1 Database Structure

In order to dis­tin­guish pages and posts in WP < 2.1, it was necessary to query the post_status column:

$result = $wpdb->get_results("SELECT post_status ...");
if ($result) {
    if ($result->post_status == "static") {
        echo "PAGE";
    } else {
        echo "POST";
    }
}

In WP >= 2.1 the database schema changed. The new column post_type was intro­duced:

$result = $wpdb->get_results("SELECT post_type ...");
if ($result) {
    if ($result->post_type == "page") {
        echo "PAGE";
    } else if ($result->post_type == "post") {
        echo "POST";
    }
}