Skip to Content.
Sympa Menu

lyceum-dev - Re: [Lyceum-dev] Widgets: MyBlogs and All Blogs

lyceum-dev AT lists.ibiblio.org

Subject: Lyceum-dev mailing list

List archive

Chronological Thread  
  • From: DaveG <lyceum AT solidgone.com>
  • To: fusion AT ibiblio.org
  • Cc: lyceum-dev AT lists.ibiblio.org
  • Subject: Re: [Lyceum-dev] Widgets: MyBlogs and All Blogs
  • Date: Sun, 30 Jul 2006 22:59:42 -0400

Jameson Lopp wrote:
$wpdb is a global variable, so before you start using it you should have the statement:

global $wpdb;

That worked great, thanks! Here's the final code (with a few HTML tweaks):

echo $before_widget;
//----------------
global $wpdb;
$wpdb->query("
CREATE TEMPORARY TABLE bloginfo
SELECT $wpdb->blogs.id, $wpdb->blogs.slug, option_value as blogname, status
FROM $wpdb->blogs
INNER JOIN $wpdb->options ON ($wpdb->blogs.id = $wpdb->options.blog)
INNER JOIN $wpdb->posts
INNER JOIN $wpdb->post2cat ON (post_id = $wpdb->posts.ID)
INNER JOIN $wpdb->categories ON (category_id = cat_ID AND $wpdb->categories.blog = $wpdb->options.blog)
WHERE
status = 'active' AND
option_name = 'blogname'
ORDER BY post_date_gmt DESC
");
$blogs = $wpdb->get_results("SELECT DISTINCT(id), slug, blogname, status FROM bloginfo");

echo $before_title . $title . $after_title . "<ul>";
if ($blogs)
if(SUBDOMAINS)
foreach ($blogs as $b)
echo "<li><a href=\"http://$b->slug.".MAINDOMAIN."\">$b->blogname</a></li>";
else
foreach ($blogs as $b)
echo "<li><a href=\"./$b->slug\">$b->blogname</a></li>";
//----------------
echo "</ul>" . $after_widget;





Archive powered by MHonArc 2.6.24.

Top of Page