get_results("select ID, post_title, post_author, date_format( post_date, '%m/%d/%Y %h:%i:%s %p' ), post_content, post_excerpt, post_status, comment_status, ping_status from $wpdb->posts order by ID asc;", ARRAY_N); if ($posts != false) { foreach ($posts as $post) { print "TITLE: " . $post[1] . "\n"; print "AUTHOR: " . $wpdb->get_var("select display_name from $wpdb->users where ID = $post[2]") . "\n"; print "DATE: " . $post[3] . "\n"; print "STATUS: " . ($post[6] == "publish" ? "Publish" : "Draft") . "\n"; print "ALLOW COMMENTS: " . ($post[7] == "open" ? "1" : "0") . "\n"; print "ALLOW PINGS: " . ($post[8] == "open" ? "1" : "0") . "\n"; //If your host uses MySQL 4.1 this should work. It definitely works with MySQL 5.0 and is faster than the other code below it which is for older hosts $categories = $wpdb->get_results("select term.name from $wpdb->terms term inner join $wpdb->term_relationships rela on term.term_id = rela.term_taxonomy_id where term.term_id in (select term_id from $wpdb->term_taxonomy where taxonomy = 'category') and rela.object_id = $post[0] order by term.name desc;", ARRAY_N); if ($categories != false) { print "PRIMARY CATEGORY: " . $categories[0][0] . "\n"; for ($x = 1; $x < count($categories); $x++) print "CATEGORY: " . $categories[$x][0] . "\n"; } $tags = $wpdb->get_results("SELECT term.name FROM $wpdb->terms term INNER JOIN $wpdb->term_relationships rela ON term.term_id = rela.term_taxonomy_id WHERE term.term_id IN (SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'post_tag' ) AND rela.object_id = $post[0] ORDER BY term.name DESC;", ARRAY_N); if ($tags != false) { print "TAGS: "; $x = 0; for ($x = 0; $x < count($tags) ; $x++) { $tag = (strripos($tags[$x][0], " ") == false ? $tags[$x][0] : "\"" . $tags[$x][0] . "\""); print ($x < count($tags) - 1 ? $tag . ", " : $tag . "\n"); } print $tags[$x][0] . "\n"; } /* $post2cat = $wpdb->get_results("select category_id from $wpdb->post2cat where post_id = $post[0];", ARRAY_N); if ($post2cat != false) { $categoryName = $wpdb->get_var("select cat_name from $wpdb->categories where cat_id =". $post2cat[0][0]); print "PRIMARY CATEGORY: " . $categoryName . "\n"; for ($x = 1; $x < count($post2cat); $x++) print "CATEGORY: " . $wpdb->get_var("select cat_name from $wpdb->categories where cat_id =". $post2cat[$x][0]) . "\n"; } */ print "-----\n"; print "BODY:\n"; print $post[4]; print "\n-----\n"; print "EXTENDED BODY:\n"; print $post[5]; print "\n-----\n"; $comments = $wpdb->get_results("select comment_author, comment_author_email, comment_author_url, comment_author_IP, date_format( comment_date, '%m/%d/%Y %h:%i:%s %p' ), comment_content, user_id from $wpdb->comments where comment_post_ID = $post[0] AND comment_type = '' order by comment_date desc;", ARRAY_N); if ($comments != false) { foreach ($comments as $comment) { print "COMMENT:\n"; print "AUTHOR: " . $comment[0] . "\n"; print "DATE: " . $comment[4] . "\n"; print "IP: " . $comment[3] . "\n"; print "EMAIL: " . $comment[1] . "\n"; print "URL: " . $comment[2] . "\n"; print $comment[5] . "\n"; print "-----\n"; } } $pings = $wpdb->get_results("select comment_author, comment_author_url, comment_author_IP, date_format( comment_date, '%m/%d/%Y %h:%i:%s %p' ), comment_content from $wpdb->comments where comment_post_ID = $post[0] AND (comment_type = 'trackback' or comment_type = 'pingback') order by comment_date desc;", ARRAY_N); if ($pings != false) { foreach ($pings as $ping) { print "PING:\n"; print "TITLE: " . $ping[0] . "\n"; print "URL: " . $ping[1] . "\n"; print "DATE: " . $ping[3] . "\n"; print "IP: " . $ping[2] . "\n"; print $ping[4]; print "-----\n"; } } print "--------\n"; } } ?>