The MU forums have moved to WordPress.org

Issues with blogname, blogdescription and post category (3 posts)

  1. philroc2
    Member
    Posted 16 years ago #

    Hello,
    the following code returns a blog name which is the same for all blogs (ie, the default blog name), an empty blog description, and empty blog-post categories. Am I doing anything wrong?

    Many thanks.

    pr

    ----------------------- code ------------------------

    <?php
    $blog_list = get_blog_list( 0, 'all' );
    foreach ($blog_list AS $blog) {
    $blog_id = $blog['blog_id'];
    $blog_path = $blog['path'];
    // retrieve last n posts
    $retrieve_last_n = 10;
    $blog_details = get_blog_details($blog_id, true);
    $post_count = $blog_details->post_count;
    $blogname = $blog_details->blogname;
    $description = get_blog_option($blog_id, 'blogdescription');
    $post_counter = 0;
    $blog_url = $blog_details->siteurl;
    echo "<b>Blog $blog_path</b> has $post_count posts.
    \n";
    echo "The program is authorized to retrieve $retrieve_last_n posts out of a total of $post_count.
    \n";
    echo "<div class='post_list'>\n";
    echo "<h5>$blogname, $blogdescription</h5>\n";
    echo "

      \n";
      for ($i = $post_count; $i >= 1; --$i) {
      $post_title = get_blog_post($blog_id, $i)->post_title;
      $post_id = get_blog_post($blog_id, $i)->ID;
      $post_name = get_blog_post($blog_id, $i)->post_name;
      $post_date = get_blog_post($blog_id, $i)->post_date;
      $post_type = get_blog_post($blog_id, $i)->post_type;
      $post_category = get_blog_post($blog_id, $i)->post_category;
      $post_author = get_blog_post($blog_id, $i)->post_author;
      $permalink = get_blog_permalink($blog_id, $i);
      if ( $post_type != 'revision' and $post_counter <= $retrieve_last_n ) {
      echo "
    • ID: $post_id, type: $post_type; title: $post_title: category: $post_category
    • \n";
      ++$post_counter;
      }
  2. philroc2
    Member
    Posted 16 years ago #

    I did a print_r of the blog details objects and here's what I got:

    stdClass Object ( [blog_id] => 7 [site_id] => 1 [domain] => abc.def.com [path]
    => /wpmu/photo/ [registered] => 2010-03-29 08:17:09 [last_updated] => 2010-04-15
    07:36:01 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0
    [lang_id] => 0 [blogname] => IHT websites [siteurl] => http://abc.def.com/wpmu
    [post_count] => 5 )

    stdClass Object ( [blog_id] => 6 [site_id] => 1 [domain] => abc.def.com [path]
    => /wpmu/style/ [registered] => 2010-03-02 14:24:35 [last_updated] => 2010-03-05
    16:06:36 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0
    [lang_id] => 0 [blogname] => IHT websites [siteurl] => http://abc.def.com/wpmu
    [post_count] => 5 )

    ...

    stdClass Object ( [blog_id] => 1 [site_id] => 1 [domain] => abc.def.com [path]
    => /wpmu/ [registered] => 2010-02-17 15:17:03 [last_updated] => 2010-04-15
    07:52:55 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0
    [lang_id] => 0 [blogname] => IHT websites [siteurl] => http://abc.def.com/wpmu
    [post_count] => 5 )

    Althought the first part of blog_details object contains data pertaining to
    each blog, the second part contains data pertaining to the default blog (wpmu/)!

  3. philroc2
    Member
    Posted 16 years ago #

    I have found something else: although $blog_details->blogname returns an empty blog name, get_blog_option($blog_id, 'blogname') returns the blog name. However, get_blog_option($blog_id, 'blogdescription') returns nothing.

About this Topic

  • Started 16 years ago by philroc2
  • Latest reply from philroc2