The MU forums have moved to

Sitewide tags plugin - Comments off (10 posts)

  1. TTjip
    Posted 15 years ago #

    Installed WPMU 2.7 and Donncha's sitewide tags plugin.
    It works but on the main blog, it shows "Comments Off"
    when the posts are from other blogs.

    Main blog: Look in the center colum under Recent Blog Posts, it shows No Comments

    Looking at the sub-blog, it says 1 Comment:

    And then looking at the post, the comment is there:

    What am I missing that it's showing Comments Off in the main blog?

  2. andrea_r
    Posted 15 years ago #

    It doesn't pull the comments, only the posts. It makes an actual copy of them.

  3. TTjip
    Posted 15 years ago #

    No wonder! Ok, so is there a way for me to pull the comments too?

  4. sepp88
    Posted 14 years ago #

    were you able to get the comments running on your MAINBLOG? how did you do that?

    thanks for your help!

  5. sepp88
    Posted 14 years ago #

  6. joshkadis
    Posted 14 years ago #

    Nice find.

    When I paste this code (unmodified) into the Sitewide Tags plugin, I get this error message when loading the ST blog:

    Parse error: syntax error, unexpected $end in /homepages/21/d170014014/htdocs/specialized/wp-content/mu-plugins/sitewide-tags.php on line 324

    Line 324 is the ?> at the end of the plugin. I don't know much PHP, but from the editor I use (Coda) it looks like the problem is with this line of code:

    $r = $wpdb->get_col(\"SELECT comment_count FROM $base{$post_blog_id}_posts WHERE ID=$post_id\");

    Anyone else have this problem?

  7. sepp88
    Posted 14 years ago #

    hey, i have the solution! for all your problems!

    first of all, get rid of the /" and the \" in the line of code you posted above.

    moreover, you will see that there is a little problem with this bit of additional code. all comments of your subblogs will get "streamed" on your main-blog. however the comments of the mainblog-posts itself won't show up.

    i tried a little bit and found the solution, it's the follwoing line.

    if (is_array($r)) return $r[0];

    replace it with...

    if (is_array($r)) return $r[0] + $count;

    and everything will work perfectly..

    so the whole working code would look like this:

    function sitewide_tags_get_comments_num($count)
      global $blog_id,$wpdb,$post;
      $tags_blog_id = get_site_option('tags_blog_id');
      if (!$tags_blog_id || $blog_id!=$tags_blog_id) return $count;
      $base = $wpdb->base_prefix;
      list($post_blog_id,$post_id) = explode('.', $post->guid);
      $r = $wpdb->get_col("SELECT comment_count FROM $base{$post_blog_id}_posts WHERE ID=$post_id");
      if (is_array($r)) return $r[0] + $count;
      return $count;
    add_filter('get_comments_number', 'sitewide_tags_get_comments_num');
  8. joshkadis
    Posted 14 years ago #

    Awesome, works like a charm! Thanks.

  9. bloggertone
    Posted 14 years ago #

    Great Solution !

    I´m still having some issue. When there is No comments, i´m having "Comments close" displayed. Is there any way to change this to "No comments" ?

    Thanks !

  10. jtcreate
    Posted 14 years ago #

    I must be missing something here... I dropped the code in right after the:
    return apply_filters('get_comments_number', $count); line in the comment-template.php file. I also commented out the 'closed' line in the sitewide tags plug in. Still shows as No Comments. Any thoughts on what might be wrong? Any help is appreciated. Thanks.

About this Topic