Is there anyway for this to just show posts and not pages because its showing both posts and pages.
<?php
$db_prefix = "wp"; //this is your database prefix, if your first user has wp_1_posts, then your prefix is "wp"
$howmany = 7; //how many rows of results do you want back?
$width = 50; //how wide do you want your rows?
/********************************************************************/
//i first tried pulling in every blog post by user, but then i lost all information about the default blog address. this became important when a guest
//user posted on somebody else's blog, at which point i'd find the user's default blog address and contstruct a wrong URL.
//define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
function get_path($userID){
global $wpdb;
$req = "select path from wp_blogs where post_parent='" . $userID . "';";
//echo $req;
$res = $wpdb->get_results($req);
$post['path'] = $res[0]->path;
return $post;
}
function bigcmp($a, $b)
{
if ($a['datetime'] == $b['datetime']) {
return 0;
}
return ($a['datetime'] < $b['datetime']) ? 1 : -1;
}
$request = "select * from wp_blogs;";
$result = $wpdb->get_results($request);
//print_r($result);
$i = 1;
foreach($result as $v1){
//get the blog name from each user and save it as $blogname to use in the next foreach
$db_table = $db_prefix . "_" . $v1->blog_id . "_options" ;
$requestx = "select option_value from " . $db_table . " where option_name='blogname' and option_id=2;";
$resultx = $wpdb->get_results($requestx);
$blogname = $resultx[0]->option_value;
//for each user get all their posts
$db_table = $db_prefix . "_" . $v1->blog_id . "_posts" ;
$request2 = "select * from " . $db_table . ";";
$result2 = $wpdb->get_results($request2);
$domain = $v1->domain;
$path = $v1->path;
//print_r($result2);
//list every post in the system
foreach($result2 as $v2){
//this part takes the date and breaks it up into year, month, day, but first save the date to use it
$array = explode(" ", $v2->post_date);
$array = explode("-", $array[0]);
$y = $array[0]; $m = $array[1]; $d = $array[2];
$allposts[$i]['datetime'] = $v2->post_date;
$string = $y . "/" . $m . "/" . $d . "/" . $v2->post_name;
$allposts[$i]['title'] = $v2->post_title;
$allposts[$i]['path'] = $v1->path;
$post_type = $v2->post_type;
/*this part gives you the post/page format, and guid URL if it's a guest poster */
//if guest user ID?
if($v2->post_type == attachment) {
}
else {
if($v2->guid !== NULL) {
$allposts[$i]['fullurl'] = $v2->guid;
$allposts[$i]['blogname'] = $blogname;
}
$i++;}
}
}
usort($allposts, "bigcmp");
//get total number of posts
$today = date('m-d-Y');
$totalposts = count($allposts);
echo '<ul>';
for($i = 0; $i < $totalposts && $i < $howmany; $i++){
if ($allposts[$i]['post_type'] == attachment)
{$howmany++;}
else {
$dateposred = explode(" ", $allposts[$i]['datetime']);
$dateposred = explode(":", $dateposred[1]);
$dateposted = explode(" ", $allposts[$i]['datetime']);
$dateposted = explode("-", $dateposted[0]);
$dateposted = $dateposted[2] . "-" . $dateposted[1] . "-" . $dateposted[0] . " o " . $dateposred[0] . ":" . $dateposred[1] . ":" . $dateposred[2];
//make the length as short as the implementer wants it
$url = substr($allposts[$i]['title'], 0, $width);
$author = "Published " . $dateposted;
$author = substr($author, 0, $width);
$blogname = $allposts[$i]['blogname'];
$blogname = substr($blogname, 0, $width);
$asd = strlen($allposts[$i]['fullurl']);
$dsa = strlen("");
if ($dsa !== $asd) {
echo '<li><a href="' . $allposts[$i]['fullurl'];
echo '" title="';
echo $author;
echo '">';
echo $url;
echo '</a>';
echo '</li>';
}
else {$howmany++;}
}
}
echo '</ul>';
?>