<?php
function showPostTitle($bid){
global $wpdb;
$mywordlimit = 6;
$postTitle = $wpdb->get_var("SELECT post_title FROM " . "wp_" . $bid . "_posts" . " WHERE post_type = 'post' ORDER BY post_date_gmt DESC");
//add a limit on the word count
//echo strip_tags(list_all_posts_summary($postTitle, $mywordlimit));
echo $postTitle;
}
function showPostDate($bid){
global $wpdb;
$postDate = $wpdb->get_var("SELECT post_date FROM " . "wp_" . $bid . "_posts" . " WHERE post_type = 'post' ORDER BY post_date_gmt DESC");
echo $postDate;
}
function showPostSummary($bid){
global $wpdb;
$mywordlimit = 22;
$postContent = $wpdb->get_var("SELECT post_content FROM " . "wp_" . $bid . "_posts" . " WHERE post_type = 'post' ORDER BY post_date_gmt DESC");
//add a limit on the word count
echo strip_tags(list_all_posts_summary($postContent, $mywordlimit));
}
function showPostPermalink($bid){
global $wpdb;
$postPermalink = $wpdb->get_var("SELECT option_value FROM " . "wp_" . $bid . "_options" . " WHERE option_name = 'siteurl'");
$myPermalink = $wpdb->get_var("SELECT id FROM " . "wp_" . $bid . "_posts" . " WHERE post_type = 'post' ORDER BY post_date_gmt DESC");
echo get_permalink($myPermalink);
}
?>
<?php
function showGetALife(){
global $wpdb;
$bid = "wp_27_posts";
$myquery = $wpdb->get_results("SELECT * FROM " . $bid . " WHERE post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 3", ARRAY_A);
if (is_array($myquery)){
reset($myquery);
foreach ($myquery as $row) {
echo "<h3>".$row[post_title]."</h3>";
$thepostauthorID = $row[post_author];
$theauthorID = $row[post_author];
$thepostauthor = $wpdb->get_var("SELECT user_login FROM wp_users WHERE id=$theauthorID");
echo "<p class='authorDate'>Posted by ".$thepostauthor." on ".$row[post_date]."</p>";
echo "<p class='postContent'>".$row[post_content]."</p>";
$thepostlink = $row[guid];
echo "<p class='permalink'>Read more »";
echo "<p class='clearingDiv'>";
}
}
}
?>
This is what I have written myself and added to the Plugins folder, activated it and it generates the content I want on 2 separate pages. I'm a total novice at this so forgive me if I have made a big mess of things.
WordPress MU 1.0 is installed. http://projectblogger.ie/get-a-life which calls the showGetALife() function is working perfectly but my other page which uses the functions above that, http://projectblogger.ie/test_page has broken at some point today too.